Transfer SQL Server Logins while Preserving SIDs

Last updated: August 28, 2026.

Database users map to server logins by SID. Recreating a login with the same name but a new SID can leave the database user orphaned.

Inspect login metadata

SELECT name, type_desc, sid, is_disabled, default_database_name
FROM sys.server_principals
WHERE type_desc IN ('SQL_LOGIN','WINDOWS_LOGIN','WINDOWS_GROUP')
  AND name NOT LIKE '##%';

SELECT name, password_hash
FROM sys.sql_logins
WHERE name = N'AppLogin';

Plan the transfer

  • Use Microsoft’s supported login-transfer scripting guidance.
  • Protect scripts containing password hashes.
  • Create Windows identities only where the account exists.
  • Verify SID equality on both servers after migration.

Reference: Microsoft transfer logins guidance.

admin

admin