Skip to main content

Fixing SQL Server Logins

Sometimes when you restore a database, the Microsoft SQL Server login SIDs don't match (especially if you restore the database from another server). So when you try to add a user to the database, you get the dreaded error....

user or role already exists in the current database

The following command will fix the problem for user timothy in the current database (NOTE: This must be the current database!):

EXEC SP_Change_Users_Login 'Auto_Fix','timothy'

This will allow the user timothy in the (current) database to synchronize information with the user timothy that is a SQL login in the master database.