Skip to main content
Microsoft SQL Server is a powerful enterprise-grade relational database management system. This guide covers installing the Countries States Cities database in SQL Server using the provided SQL scripts.
SQL Server installation typically takes 5-10 minutes and requires approximately 250MB of disk space.

Prerequisites

Before starting, ensure you have:
  • SQL Server 2016+ (SQL Server 2019+ recommended)
  • SQL Server Management Studio (SSMS) or Azure Data Studio
  • Administrative access to your SQL Server instance
  • At least 500MB free disk space
  • Downloaded the sqlserver/world.sql file from our GitHub repository
SQL Server provides advanced enterprise features like partitioning, columnstore indexes, and in-memory processing that can significantly improve performance for large datasets.

Method 1: SQL Server Management Studio (SSMS)

1

Create Database

Adjust the file paths according to your SQL Server data directory. Default is usually C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\.
2

Execute SQL Script

  • Open SSMS and connect to your server
  • Open a new query window
  • Set the database context: USE [world]
  • Open the sqlserver/world.sql file
  • Execute the script (F5)
The script includes table creation, data insertion, and index creation optimized for SQL Server.
3

Verify Installation

Expected output:

Method 2: Command Line (sqlcmd)

1

Create Database

Or for SQL Server Authentication:
2

Import SQL File

Use -U username -P password instead of -E if not using Windows Authentication.
3

Verify Installation

Method 3: Import/Export Wizard

1

Launch Import Wizard

  • Right-click on the database in SSMS
  • Select “Tasks” → “Import Data”
  • Choose “SQL Server Native Client” as data source
2

Configure Source

  • Server name: your SQL Server instance
  • Authentication: Windows or SQL Server
  • Database: select source if importing from another SQL Server
3

Select Destination

  • Choose your target world database
  • Select tables to import
  • Configure any data type mappings

Advanced Configuration

Create Application User and Login

1

Create Login

Use a strong password that meets your organization’s security requirements.
2

Create Database User

Performance Optimization

Memory-Optimized Tables

Database Structure Verification

Connection Examples

Enterprise Features

Spatial Data and Geography

Troubleshooting

Problem: A network-related or instance-specific error occurredSolutions:
  1. Check if SQL Server service is running
  2. Verify SQL Server Browser service is running
  3. Check firewall settings (default port 1433)
  4. Enable TCP/IP protocol in SQL Server Configuration Manager
  5. Verify connection string format
Problem: Login failed for userSolutions:
  1. Check username and password
  2. Verify SQL Server authentication mode (Mixed Mode vs Windows)
  3. Check user permissions: SELECT * FROM sys.server_principals
  4. Ensure user is mapped to database: SELECT * FROM sys.database_principals
  5. Check if account is locked or disabled
Problem: Import fails with memory errorsSolutions:
  1. Increase SQL Server max memory setting
  2. Import data in smaller batches
  3. Temporarily disable indexes during import
  4. Check available disk space for tempdb
  5. Monitor memory usage during import
Problem: Queries are running slowlySolutions:
  1. Check execution plans using SET STATISTICS IO ON
  2. Create appropriate indexes (see Performance section)
  3. Update statistics: UPDATE STATISTICS table_name
  4. Check for missing indexes: sys.dm_db_missing_index_details
  5. Consider columnstore indexes for analytical queries

Backup and Maintenance

Backup Strategy

Maintenance Tasks

Use SQL Server Maintenance Plans to automate backup, index maintenance, and statistics updates for production environments.

Next Steps

After successful installation:
  1. Configure security with proper user roles and permissions
  2. Set up monitoring with SQL Server Management Studio or third-party tools
  3. Implement backup strategy including full, differential, and log backups
  4. Optimize for your workload using columnstore indexes or partitioning
  5. Configure Always On availability groups for high availability

Need Help?

Join our community discussions for SQL Server-specific questions and enterprise optimization tips.