Home » Blog » SQL Server » How to Perform a SQL Server Migration?

How to Perform a SQL Server Migration?

Neeraj Kumar
Published By Neeraj Kumar
Debasish Pramanik
Approved By Debasish Pramanik
Published On
Last Updated

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:

TypeExampleGuide
Same versionOld server to new hardwareTransfer Data Between Two SQL Servers
Newer versionSQL Server 2014 to 2022Migrate SQL Server 2014 to 2022
Older server retiredSQL Server 2012 to 2019Migrate SQL Server 2012 to 2019
CloudSQL Server to Azure SQL DatabaseMigrate SQL Server to Azure

Which Checks Come Before a SQL Server Migration?

Seven checks come first:

  1. Record the source version, edition and service pack.
  2. Decide how much downtime the business accepts.
  3. Create backups before anything else. The Explore Different Types of Backups in SQL Server guide has every backup script.
  4. Note the collation of your databases and match it on the destination.
  5. List the logins, linked servers and Agent tasks of the application.
  6. Confirm free disk space on the destination for the data and log files.
  7. 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.

MethodBest ForMain Limit
Backup and RestoreMost migrationsLogins move separately
Detach and AttachLarge data filesSource goes offline
Copy Database WizardMoving logins with the databaseNeeds sysadmin rights
BACPAC FileDifferent versions and editionsSlow on large databases
Migration SoftwareLive databases and MDF filesTrial 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:

  1. Right click the database in Object Explorer and select Tasks and then Back Up.
  2. Add a destination path and click OK.
  3. Move the backup file to the new server.
  4. Right click Databases on the new server and select Restore Database.
  5. 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:

  1. Right click the database and select Tasks and then Detach.
  2. Move the MDF and LDF files to the destination server.
  3. Right click Databases on the destination and select Attach.
  4. 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:

  1. Right click the database and select Tasks and then Copy Database.
  2. Enter the destination server and the authentication.
  3. Select the transfer method.
  4. Mark Copy so the source database remains online.
  5. 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:

  1. Right click the database and select Tasks and then Export Data-tier Application.
  2. Save the file to a local disk with the .bacpac extension.
  3. Right click Databases on the destination and select Import Data-tier Application.
  4. 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:

  1. Start the software and click Open. Start screen of the software
  2. Select Online mode for a live server. Online and Offline mode options
  3. Add the Server Name with Authentication of the source. Login window for the source server
  4. Select the database from the Drop Down List and click OK. Database list of the source server
  5. Expand the tree and inspect tables, views and stored procedures. Preview of the database objects
  6. Click Export. Export button

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:

  1. Select SQL Server Database to export to a server or SQL Server Compatible SQL Scripts to create script files. Four export options
  2. Add the Server Name with Authentication of the destination. Login window for the destination server
  3. Choose Create New Database or Export to Existing Database. Destination database options
  4. Set Collation Settings to match the source. The software uses the server default when you select nothing. Collation settings
  5. Tick the objects to move. Object selection
  6. Choose With only Schema for structure or With Schema & Data for rows. Schema and data options
  7. Click Save and close the Export Completed message. 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:

  1. Create a fresh backup of every migrated database.
  2. Verify the database owners and the logins of the application:
SELECT name, SUSER_SNAME(owner_sid) AS owner FROM sys.databases;
  1. Refresh the statistics:
USE ShopDB;
EXEC sp_updatestats;
  1. Check the compatibility level and raise it only after application tests:
SELECT name, compatibility_level FROM sys.databases;
  1. 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:

ProblemReasonFix
Restore failsBackup is from a newer releaseRestore on the same or a newer version
Application cannot log inLogins stayed on the old serverCreate the logins on the new server
Attach failsMDF file is damaged or the log is missingOpen the file with Advance Scan in Offline mode
Database name existsDestination has the same nameExport to a new database name
Collation conflictCollations differ between serversMatch 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.
  Neeraj Kumar

By Neeraj Kumar

Neeraj Kumar is a Principal Technical Architect at EmailDoctor with 19+ years of experience in email migration, cloud migration, data recovery and digital forensics. He guides enterprise teams through Exchange, Office 365 and Google Workspace projects and shares what works as an EmailDoctor writer. Every method in his posts is tested on Windows and Mac before it goes live.