Knowledgebase
Recovering Orphaned Database Users
Posted by on 25 August 2012 10:23 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.

(2 vote(s))
Helpful
Not helpful

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