Raja Afrika of the Afrika 8
Sunday, December 22, 2024
 
Back to Raja's Blog

Raja's Blog
Not All Who Wander Are Lost

Fixing Orphaned Users in SQL Server
Posted: Thursday, April 9, 2009

The problem is that the user in the database is an "orphan". This means that there is no login id or password associated with the user. This is true even if there is a login id that matches the user, since there is a GUID (called a SID in Microsoft-speak) that has to match as well.


All of these instructions should be done as a database admin, with the restored database selected.


First, make sure that this is the problem. This will lists the orphaned users:



EXEC sp_change_users_login 'Report'



If you already have a login id and password for this user, fix it by doing:



EXEC sp_change_users_login 'Auto_Fix', 'user'



If you want to create a new login id and password for this user, fix it by doing:



EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password'