Re-map an existing database user to an existing SQL Server login

1/27/2012 9:29:45 AM

After a database restore the database will have its user but the SQL Server login havent't been created. Fix the mapping by adding the SQL Server login and then map them together using sp_change_users_login sproc.

It wont work to map them using SSMS as the database user "already exists".

EXEC spchangeuserslogin 'UpdateOne', 'databaseUserName', 'sqlServerLoginName';

MSDN on spchangeusers_login.