SQL

Migrate a SQL Server Instance to a New Server in 6 Steps

10 min read

Migrate a SQL Server instance by moving the databases and everything that lives outside them. Microsoft lists 17 types of server level information that do not travel with a restored database.

Six steps follow, in the order that avoids broken logins and missing jobs. Step 2 moves the databases and links to the full database guide.

Quick SummaryMigrate a SQL Server instance in six steps. List the server level items on the old server first. Move the user databases with backup and restore. Script the logins with their password hashes and SIDs. Recreate the jobs, the linked servers and the credentials. Fix orphaned users and test every application before the cutover.

What Moves With the Databases and What Does Not?

A backup of a database holds the data and the objects of that database. The logins, the jobs and the linked servers live in the master and msdb databases of the old server, so the backup does not include them.

Microsoft lists the items in its page on metadata for a database on another server. Your instance needs only the items it uses. The table shows the items that most instances need.

Which Server Level Items Need a Manual Move?

Item Lives in How you move it
Logins and server permissions master Script with sp_help_revlogin (Step 3)
SQL Server Agent jobs msdb Script in SSMS (Step 4)
Credentials and proxies master and msdb Recreate before the jobs (Step 4)
Linked servers master Script in SSMS (Step 4)
Server level triggers master Script and execute on the new server
User defined messages master Add again with sp_addmessage
Server configuration options master Compare sp_configure output on both servers
Replication settings msdb and the distributor Recreate the publications and subscriptions
Service Broker routes msdb Recreate the routes
Encrypted data keys The database and master Open the database master key on the new server

Do You Know?Microsoft states that replication settings cannot be preserved and that Service Broker, trustworthy and broker priority options are OFF after an attach. Plan these items before the cutover and not after.

How to Migrate a SQL Server Instance to a New Server?

Every example uses the database SalesDB. Replace the names and the paths with your own values.

Step 1: Inventory the Old Instance

Query the old server for the items in the table. Save the output next to your migration notes.

SELECT @@VERSION AS version, SERVERPROPERTY('Collation') AS server_collation;

SELECT name, value_in_use
FROM sys.configurations
ORDER BY name;

SELECT name, type_desc, is_disabled
FROM sys.server_principals
WHERE type IN ('S', 'U', 'G') AND name NOT LIKE '##%';

SELECT name, enabled
FROM msdb.dbo.sysjobs;

SELECT name, data_source, product
FROM sys.servers
WHERE is_linked = 1;

Install the new instance with the same server collation as the old instance. Compare the sp_configure values and enable the features that your databases use.

Step 2: Move the User Databases

Backup and restore moves a database with the least risk. Migrate a SQL Server database to a new server shows four ways with the full steps.

BACKUP DATABASE SalesDB
TO DISK = N'D:\Backup\SalesDB.bak'
WITH CHECKSUM, STATS = 10;

RESTORE VERIFYONLY
FROM DISK = N'D:\Backup\SalesDB.bak'
WITH CHECKSUM;

RESTORE DATABASE SalesDB
FROM DISK = N'E:\Backup\SalesDB.bak'
WITH RECOVERY, STATS = 10;

Microsoft states that SQL Server upgrades an earlier version database automatically after the restore and that the upgrade has no way back. Follow SQL Server error 3169 when the new server uses an older version than the backup.

Use SQL Server Migrator when backup and restore is not possible. SQL Server Migrator opens a live SQL Server in online mode or an MDF file in offline mode and exports the schema and the records to a SQL Server database or to SQL script files.

Download SQL Server Migrator Buy SQL Server Migrator

  1. Install SQL Server Migrator and click Open to add the database.

Open button in SQL Server Migrator

  1. Select Online Mode for a live server and choose Live SQL Server with Authentication. Select Offline Mode to add an MDF file with Quick Scan or Advance Scan.

Live SQL Server selection in SQL Server Migrator

  1. Click Export and select SQL Server Database. Select the destination server and choose Create New Database or Export to Existing Database. Choose With only Schema or With Schema & Data and click Save.

Schema and data export options in SQL Server Migrator

Step 3: Move the Logins

Logins live in master, so a restore never brings them. Microsoft documents two methods in its page on transferring logins and passwords.

Method Result
sp_help_revlogin Creates every login with the original password hash and the original SID
Generate Scripts with Script Logins set to True Creates SQL logins as disabled with a random password

Create the sp_hexadecimal and sp_help_revlogin procedures from the Microsoft page in master on the old server. Execute the procedure and execute the output on the new server.

EXEC sp_help_revlogin;

ALTER LOGIN [app_user] WITH DEFAULT_DATABASE = [SalesDB];

The output creates every login with the HASHED password and the original SID. Microsoft names four traps. The script omits the default database. Servers in different domains give Windows logins new SIDs. A SID that exists already returns error 15433 and a login name that exists already returns error 15025. A difference in case sensitivity between the two servers breaks passwords with letters.

Step 4: Recreate Jobs, Linked Servers and Credentials

Create the credentials and the proxies first because the jobs need them. Microsoft states that every proxy a job uses must exist on the new server before the job starts.

  1. Open SQL Server Agent then Jobs in Object Explorer on the old server and select the jobs in the Object Explorer Details pane.
  2. Right click the selection and select Script Job as, then CREATE To, then New Query Editor Window.
  3. Execute the script on the new server and repeat the steps for Server Objects and Linked Servers.

Match the SQL Server Agent service account on both servers. Enter the passwords of the credentials and the linked server logins by hand because the scripts omit secrets.

Step 5: Fix Orphaned Users

An orphaned user is a database user without a matching login. Microsoft names the case as a database restored, attached or copied to another instance.

USE SalesDB;

SELECT dp.type_desc, dp.sid, dp.name AS user_name
FROM sys.database_principals AS dp
LEFT JOIN sys.server_principals AS sp ON dp.sid = sp.sid
WHERE sp.sid IS NULL AND dp.authentication_type_desc = N'INSTANCE';

ALTER USER [app_user] WITH LOGIN = [app_user];

ALTER AUTHORIZATION ON DATABASE::SalesDB TO [sa];

The first query lists the orphaned users. ALTER USER maps a user to a login with another SID. The last statement sets the database owner because the login that restores a database becomes its owner. Follow SQL Server error 15023 when a statement reports that the user already exists.

Step 6: Test and Cut Over

Test the new server with a copy of production traffic before the cutover. Check the items in the table.

Check Statement or action
Application sign in Connect with the real connection string from the application server
Jobs EXEC msdb.dbo.sp_start_job N’JobName’;
Linked servers EXEC sp_testlinkedserver N’LinkedServerName’;
Database health DBCC CHECKDB on every moved database
Backups A full backup and a log backup on the new server

Point the application to the new server after the tests pass. Retain the old server offline for a rollback window that matches your recovery plan and never delete the old files on the cutover day.

What Does SQL Server Migrator Need on Your System?

Check both tables before you install SQL Server Migrator on the old server or on a separate workstation.

Software Specifications

Attribute Detail
Software name SQL Server Migrator
Version 6.1.0
Source Live SQL Server in online mode and MDF file in offline mode
Destination SQL Server, Azure SQL Database, MySQL and SQL script files
Objects Tables, views, stored procedures, triggers, functions and others
Export options Schema only or schema with data, new or existing database and primary and foreign keys
SQL Server versions 2025, 2022, 2019, 2017, 2016, 2014, 2012, 2008 R2, 2008, 2005 and 2000
Demo limit Export of 25 records per table and 5 records from every other category

System Specifications

Component Requirement
Processor Intel Core 2 Duo E4600 at 2.40 GHz or equivalent
RAM 4 GB
Hard disk space 100 MB free
Operating system Windows 7, 8 and 10 (32 or 64 bit), Windows 11 (64 bit), Windows Server 2008, 2012 R2, 2016, 2019, 2022 and 2025
Framework Microsoft .NET Framework 4.5 or later
Permission Launch SQL Server Migrator as administrator

Common Questions on Instance Migration

Can You Restore master and msdb on the New Server to Move Logins and Jobs?

No. Microsoft states that backups of master, model and msdb from an earlier version cannot restore on a later version. Script the logins and the jobs instead.

Do SQL Logins Retain Their Passwords When You Script Them?

The answer depends on the method. sp_help_revlogin keeps the password hash and the SID. The Generate Scripts Wizard creates SQL logins as disabled with a random password and you must reset them.

Why Do Users Fail to Sign In After the Move?

Microsoft names orphaned users as the cause. The database users exist but the matching logins do not exist on the new server, so sign in fails with error 18456.

Do Contained Databases Need a Login Transfer?

No. Contained databases store their own users, so the users move with the database.

Do Availability Groups Need the Logins on Every Replica?

Yes. Microsoft states that you transfer the logins to every replica and every node of a failover cluster instance.

Does SQL Server Migrator Move Logins and Jobs?

No. The product page lists tables, views, stored procedures, triggers and functions as the exported objects. Script the logins and the jobs with Steps 3 and 4.

How to Plan the Next Instance Move?

Store the scripts for logins, jobs and linked servers in source control after every move. The next migration then starts with a tested script and not with a blank page.

Review the logins before the move. SQL Server security best practices lists the accounts that deserve a cleanup first.

Who, How and WhyAndrew Jackson, Technical Content Specialist, wrote this guide. The list of server level items, the proxy rule and the orphaned user definition follow the Microsoft page on metadata for a database on another server. The login transfer methods, the SID rules and the error numbers follow the Microsoft page on transferring logins and passwords. The T-SQL was checked for syntax against Microsoft documentation and was not executed on a live server. The SSMS scripting path, the job and linked server test statements and the cutover table come from general practice and not from a Microsoft page. The SQL Server Migrator steps and tables follow the screens and the product page of the software. The guide did not test a full instance move on live servers. The guide exists because a restored database fails to serve users when the logins and the jobs remain on the old server.

Key Takeaways

  • A database backup includes no logins, jobs or linked servers because they live in master and msdb.
  • Microsoft lists 17 types of server level information that need a manual move.
  • sp_help_revlogin keeps the password hash and the SID of every login.
  • Generate Scripts creates SQL logins as disabled with a random password.
  • Orphaned users cause error 18456 until you map them to a login with ALTER USER.
  • SQL Server Migrator exports the schema and the records when backup and restore is not possible.