/
How to synchronize the database users between instances
How to synchronize the database users between instances
Aim
In certain cases you will be required to synchronize the users between multiple SQL servers instances:
New deployment of an SQL always on instance
Configuration of SQL always on
Migrating the database into a new SQL instance
Instructions
Follow these steps to restore the users:
Run the following query to get the orphaned users SID and login
USE [DB_Name] -- Get the user's SID EXEC SP_CHANGE_USERS_LOGIN 'REPORT'
Copy the UserName and UserSID values and paste them in the appropriate field in the following command:
USE [master]
--Create the login
CREATE LOGIN <UserName> WITH PASSWORD = '<yourPassword>', sid=<UserSID>
Connect to the database with that user and run a SELECT query on one of that tables to validate permissions.