Skip to content

Commit 9bb5923

Browse files
committed
initial updates
1 parent 815e17d commit 9bb5923

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

support/sql/database-engine/security/transfer-logins-passwords-between-instances.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
---
2-
title: Transfer logins and passwords between instances
3-
description: This article describes how to transfer the logins and the passwords between different instances of SQL Server running on Windows.
2+
title: Transfer SQL Server Logins and Passwords Between Instances
3+
description: Learn how to transfer logins and passwords between SQL Server instances to maintain user access and security during migrations or restores.
44
ms.date: 01/17/2025
55
ms.custom: sap:Security, Encryption, Auditing, Authorization
6-
ms.reviewer: jopilov
7-
ms.author: bartd
6+
ms.reviewer: jopilov, bartd, v-shaywood
87
ms.topic: how-to
98
---
109

1110
# Transfer logins and passwords between instances of SQL Server
1211

13-
This article describes how to transfer the logins and passwords between different instances of Microsoft SQL Server running on Windows. The instances might be on the same server or different servers, and their versions might differ.
14-
1512
_Original product version:_   SQL Server
1613
_Original KB number:_   918992, 246133
1714

15+
## Summary
16+
17+
This article describes how to transfer the logins and passwords between different instances of Microsoft SQL Server running on Windows. Use these procedures when you migrate databases between servers or need to maintain consistent user access across SQL Server instances. The instances might be on the same server or different servers, and their versions might differ.
18+
1819
## Why transfer logins between SQL Server instances?
1920

20-
In this article, server A and server B are servers.
21+
When you move a database to a new server (like in a migration or restore), the database users are moved, but their corresponding server-level logins might not exist on the new instance, creating orphaned users. Transferring login and passwords is crucial for maintaining security and access continuity.
2122

2223
After you move a database from a SQL Server instance on server A to a SQL Server instance on server B, users might be unable to log in to the database server on server B. Additionally, users might receive the following error message:
2324

2425
> Login failed for user '**MyUser**'. (Microsoft SQL Server, Error: 18456)
2526
2627
This problem occurs because the logins from the SQL Server instance on server A don't exist in the SQL Server instance on server B.
2728

28-
Keep in mind that error 18456 occurs for many other reasons. For more information on these causes and their resolutions, see [MSSQLSERVER_18456](/sql/relational-databases/errors-events/mssqlserver-18456-database-engine-error).
29+
Error 18456 can also occur for several other reasons. For more information on the various causes and their resolutions, see [MSSQLSERVER_18456](/sql/relational-databases/errors-events/mssqlserver-18456-database-engine-error).
2930

3031
## Steps to transfer logins between SQL Server instances
3132

3233
To transfer the logins, use one of the following methods, as appropriate for your situation.
3334

34-
### Method 1: Generate scripts via SSMS on the source server and manually reset passwords for SQL Server logins on the destination server
35+
### Method: Generate scripts via SSMS on the source server and manually reset passwords for SQL Server logins on the destination server
3536

36-
You can generate login scripts in SQL Server Management Studio (SSMS) by using the [Generate Scripts option for a database](/sql/ssms/tutorials/scripting-ssms#script-a-database-by-using-the-generate-scripts-option).
37+
You can generate login scripts in SQL Server Management Studio (SSMS) by using the [Generate Scripts option for a database](/sql/ssms/tutorials/scripting-ssms#script-a-database-by-using-the-generate-scripts-option).
3738

3839
To generate scripts via SSMS on the source server and manually reset passwords for SQL Server logins on the destination server, follow these steps:
3940

@@ -51,12 +52,12 @@ To generate scripts via SSMS on the source server and manually reset passwords f
5152
`/* For security reasons the login is created disabled and with a random password. */`
5253

5354
> [!NOTE]
54-
> This indicates that the SQL Server Authentication logins are generated with a random password and are disabled by default. You need to reset the password and re-enable these logins on the destination server.
55+
> This comment indicates that the SQL Server Authentication logins are generated with a random password and are disabled by default. You need to reset the password and re-enable these logins on the destination server.
5556
5657
1. Apply the login script from the larger generated script to the destination SQL Server.
5758
1. For any SQL Server Authentication logins, reset the password on the destination SQL Server and re-enable those logins.
5859

59-
### Method 2: Transfer logins and passwords to the destination server (Server B) using scripts generated on the source server (Server A)
60+
### Method: Transfer logins and passwords to the destination server (Server B) by using scripts generated on the source server (Server A)
6061

6162
1. Create stored procedures that will help generate necessary scripts to transfer logins and their passwords. To do so, connect to Server A using SQL Server Management Studio (SSMS) or any other client tool and run the following script:
6263

@@ -275,7 +276,7 @@ To generate scripts via SSMS on the source server and manually reset passwords f
275276
> [!NOTE]
276277
> This script creates two stored procedures in the master database. The procedures are named **sp_hexadecimal** and **sp_help_revlogin**.
277278

278-
1. In the SSMS query editor, select the **[Results to Text](/sql/ssms/f1-help/database-engine-query-editor-sql-server-management-studio)** option.
279+
1. In the SSMS query editor, select the [Results to Text](/sql/ssms/f1-help/database-engine-query-editor-sql-server-management-studio) option.
279280

280281
1. Run the following statement in the same or a new query window:
281282

0 commit comments

Comments
 (0)