SQL Server Fix Orphaned User

When cloning databases in SQL Server from one server to another, you can run into the problem where the userid that is associated with the database is not valid in the security of the database engine that is hosting the new database.

An easy fix to this problem is to run the following statement:

EXEC sp_change_users_login ‘Auto_Fix’, ‘user

You can list all the users that are orphaned by running the following statement:

EXEC sp_change_users_login ‘Report’