Knowledgebase: MSSQL Server
Recovering Orphaned Database Users
Posted by on 18 February 2013 06:29 PM

Often, when restoring a database from a remote machine on my local development machine, my user logins no longer work for that database. The problem lies with the fact that while the user name is the same from machine to machine, the underlying GUID that SQL uses to identify users is different. Thankfully, there is a very easy one line command that fixes these "orphaned" users.

In the context of the database with the orphaned user, run:

EXEC sp_change_users_login 'Auto_Fix, 'username'

Of course, substitute the actual user name for the placeholder in the above script.

(0 vote(s))
Not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).