Map exisiting SQL Server logins
Posted by CJ on February 28, 2008
Stored in Vault
I always forget this system procedure sp_change_user_login. You need this when you perform a database backup/restore from one SQL Server to another. The restore process doesn’t map database logins with SQL Server logins so in effect you have an orphaned database login. You can’t simply delete this account either so what we want to do is remap the database login to the SQL Server login.
sp_change_users_login
EXEC sp_change_users_login ‘Update_One’, ‘MaryB’, ‘MaryB’;
There are a couple of other options:
Report allows you to list all orphaned users
Auto_Fix checks if a database login and to SQL login have the same name, if not it creates ones.