Instructions provided describe how to re-synch SQL Server logins with the database users after restoring a database from backup.

The following code will show all the users which orphaned.

EXEC sp_change_users_login 'Report';

The following will fix the issue.

If there is already login which can be mapped to database user to, run the following (first instance of ‘db_login1’ is the user in the database, the second instance is the login to be mapped to):

EXEC sp_change_users_login 'update_one', 'db_login1', 'db_login1';

Categorized in:

SQL,

Last Update: May 18, 2024