As a developer I find that I’m frequently backing up and restoring SQL Server databases between servers for development and testing purposes. However, each time I do the link between the login (a server concept) and the user (a per database concept) gets broken.
There is a stored procedure in SQL Server to wire it all back up again and I keep forgetting what it is. So here it is (my aide memoir):
sp_change_users_login: It maps an a database user to a SQL Server login.
The quick and easy way is as follows:
sp_change_users_login 'Update_One', 'myUserName', 'myLoginName'