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.
Senior Engineer Jessie
Comments