A SQL Server migration moves databases from one server to another. Five methods fit different needs. Backup and restore suits most moves. Detach and attach copies the data files. Copy Database Wizard moves logins with the database. A BACPAC file works across versions and editions. Migration software exports live databases and MDF files to a server or to SQL scripts. Check the compatibility level afterward.
Every SQL Server migration starts with the same question about downtime and tools. Hardware refreshes, version upgrades, cloud moves and mergers all raise it.
Most guides explain one tool and ignore the planning. Few compare the options or show what breaks after the move.
This guide explains five methods for SQL Server migration, with a checklist before the move and the tasks after it.
Microsoft describes the Copy Database Wizard and backup based moves in its copy databases to other servers article.
Why Plan a SQL Server Migration?
Four events trigger most migrations:
- Hardware. Old servers reach the end of their life and need replacement.
- Versions. Older releases lose support. Teams move to a newer SQL Server.
- Cloud. Companies move databases to Azure to cut maintenance.
- Mergers. Combined companies consolidate databases on fewer servers.
Microsoft states that a database from a newer release cannot attach to an earlier version. Plan every migration as a one way move.
What Types of SQL Server Migration Exist?
Four types fit almost every project:
| Type | Example | Guide |
|---|---|---|
| Same version | Old server to new hardware | Transfer Data Between Two SQL Servers |
| Newer version | SQL Server 2014 to 2022 | Migrate SQL Server 2014 to 2022 |
| Older server retired | SQL Server 2012 to 2019 | Migrate SQL Server 2012 to 2019 |
| Cloud | SQL Server to Azure SQL Database | Migrate SQL Server to Azure |
Which Checks Come Before a SQL Server Migration?
Seven checks come first:
- Record the source version, edition and service pack.
- Decide how much downtime the business accepts.
- Create backups before anything else. The Explore Different Types of Backups in SQL Server guide has every backup script.
- Note the collation of your databases and match it on the destination.
- List the logins, linked servers and Agent tasks of the application.
- Confirm free disk space on the destination for the data and log files.
- Prepare a test copy and a rollback plan.
5 Methods for SQL Server Migration
Four methods use tools from Microsoft and the fifth adds software for live databases and MDF files.
| Method | Best For | Main Limit |
|---|---|---|
| Backup and Restore | Most migrations | Logins move separately |
| Detach and Attach | Large data files | Source goes offline |
| Copy Database Wizard | Moving logins with the database | Needs sysadmin rights |
| BACPAC File | Different versions and editions | Slow on large databases |
| Migration Software | Live databases and MDF files | Trial record limit |
Method #1: Restore a Backup on the New Server (Free, Best Default)
Backup and restore is the standard path because the source database remains untouched. Five steps restore the database:
- Right click the database in Object Explorer and select Tasks and then Back Up.
- Add a destination path and click OK.
- Move the backup file to the new server.
- Right click Databases on the new server and select Restore Database.
- Select Device, add the file and click OK.
Note: Logins sit in the master database. Create them on the new server by hand. Restore dialogs are explained in Restore a SQL Database From a BAK File.
Method #2: Detach and Attach the Data Files (Free, Source Goes Offline)
Detach frees the MDF and LDF files so you can move them. Four steps move the files:
- Right click the database and select Tasks and then Detach.
- Move the MDF and LDF files to the destination server.
- Right click Databases on the destination and select Attach.
- Click Add, select the MDF file and click OK.
Note: Attach upgrades the database to the newer release when the destination is newer. Keep your backup because the upgrade cannot be reversed.
Method #3: Use Copy Database Wizard (Free, Moves Logins)
Copy Database Wizard moves the database and the logins that belong to it. The wizard needs the sysadmin role on both servers. Five steps copy the database:
- Right click the database and select Tasks and then Copy Database.
- Enter the destination server and the authentication.
- Select the transfer method.
- Mark Copy so the source database remains online.
- Add the logins on the server objects page and finish the wizard.
Note: Express edition does not include the wizard. The Copy SQL Database From One Server to Another guide compares both transfer methods.
Method #4: Move a BACPAC File (Free, Works Across Editions)
A BACPAC file packs the schema and data of a single database. Four steps export and import the file:
- Right click the database and select Tasks and then Export Data-tier Application.
- Save the file to a local disk with the .bacpac extension.
- Right click Databases on the destination and select Import Data-tier Application.
- Browse to the file and type the new database name.
Note: BACPAC files include the database but not the logins. Microsoft recommends the SqlPackage tool for large databases.
Method #5: Migrate a Live SQL Server Database With EmailDoctor (Free Preview, Paid Export)
EmailDoctor SQL Server Data Migration Tool handles four routes from one window. The migration software moves data from a live server to a live server or to SQL scripts and exports offline MDF files to a live server or to SQL scripts.
Trial mode previews every object. Exports in trial stop at 25 records per table and 5 other categories until you buy a license.
Connect to the Source Server
Six steps connect to the source and show its objects:
- Start the software and click Open.
- Select Online mode for a live server.
- Add the Server Name with Authentication of the source.
- Select the database from the Drop Down List and click OK.
- Expand the tree and inspect tables, views and stored procedures.
- Click Export.
Note: Offline mode opens an MDF file that no server uses. Select Advance Scan when the file is damaged.
Export to the Destination Server
Seven steps send the database to the destination:
- Select SQL Server Database to export to a server or SQL Server Compatible SQL Scripts to create script files.
- Add the Server Name with Authentication of the destination.
- Choose Create New Database or Export to Existing Database.
- Set Collation Settings to match the source. The software uses the server default when you select nothing.
- Tick the objects to move.
- Choose With only Schema for structure or With Schema & Data for rows.
- Click Save and close the Export Completed message.
Note: The software does not perform a redundancy check. Export to a new database when the destination already has objects with the same names.
Which Tasks Follow a SQL Server Migration?
Five tasks follow every method:
- Create a fresh backup of every migrated database.
- Verify the database owners and the logins of the application:
SELECT name, SUSER_SNAME(owner_sid) AS owner FROM sys.databases;
- Refresh the statistics:
USE ShopDB;
EXEC sp_updatestats;
- Check the compatibility level and raise it only after application tests:
SELECT name, compatibility_level FROM sys.databases;
- Test the application and save the old server for one week.
Microsoft states that a restored backup retains its compatibility level when the level is 100 or higher. Raise the level on purpose and not by accident.
Which Problems Stop a SQL Server Migration?
Five problems appear most:
| Problem | Reason | Fix |
|---|---|---|
| Restore fails | Backup is from a newer release | Restore on the same or a newer version |
| Application cannot log in | Logins stayed on the old server | Create the logins on the new server |
| Attach fails | MDF file is damaged or the log is missing | Open the file with Advance Scan in Offline mode |
| Database name exists | Destination has the same name | Export to a new database name |
| Collation conflict | Collations differ between servers | Match the collation or set it during export |
Frequently Asked Questions
What is SQL Server Migration?
SQL Server migration moves databases, data and objects from one server to another. The destination can use the same version or a newer one.
Which Method Gives the Safest SQL Server Migration?
Backup and restore. The source database remains online and untouched while you restore a copy on the new server.
Does SQL Server Migration Need Downtime?
Yes for backup and restore, detach and attach and BACPAC files. Plan a short window for the final cutover and update the connection strings.
Do Logins Travel With the Database?
No. Logins sit in the master database. Copy Database Wizard can move them. With the other methods you create the logins by hand.
Can I Migrate a SQL Server Database to an Older Version?
No. A database from a newer release cannot attach to an earlier version. Restore the backup on the same or a newer version.
Can I Migrate an MDF File When the Server is Down?
Yes. Select Offline mode in the migration software, browse to the MDF file and export the objects to a server or to SQL scripts.
Which SQL Server Versions Does the Migration Software List?
Vendor notes list SQL Server 2000 through 2019. Test newer releases with the free trial first.
Does the Trial Export All Tables?
No. Trial exports include 25 records per table and 5 other categories. A license removes the cap.
Author’s Verdict
Backup and restore suits most migrations because the source remains untouched. Detach and attach saves time on large files but takes the source offline.
Copy Database Wizard moves logins. BACPAC files work across editions. Migration software fits live databases, MDF files and script output.
Test the application on the new server before the cutover. Save the old backups and the old server for a week.
- Five methods perform a SQL Server migration.
- Backup and restore suits most moves.
- Detach and attach copies data files.
- Copy Database Wizard moves logins.
- BACPAC files cross editions.
- Migration software handles live databases and MDF files.
- Create the logins, refresh the statistics and check the compatibility level afterward.
Next Read: Migrate SQL Server to Azure
Also Read: Migrate SQL Server 2014 to 2022 | Merge Two SQL Server Databases