binary dreams

a world of 1s and 0s

How to fix orphaned SQL login users

If ever you have the message that the login failed it may be because of an orphaned user.

Run this to check what orphaned users you have.

EXEC sp_change_users_login 'REPORT'

Then run this to fix it. Where ‘LoginName’ is the login and then the user it is attached to.

EXEC sp_change_users_login'UPDATE_ONE','LoginName','LoginName'

From this website http://mcpmag.com/articles/2011/02/17/fixing-sql-server-2008-database-orphans.aspx