Find and Fix MSSQL Orphaned DB User |
![]() |
![]() |
![]() |
Written by Tim Andaya |
Thursday, 05 August 2010 15:44 |
-- Get Information about orphaned users EXEC sp_change_users_login 'Report' -- Revoke access to bad users not in system exec sp_revokedbaccess '(USER)' -- or map orphaned user to good user -- Note: the orphaned user name may be the same as the good user -- - name, they just have different system ID information (SID). -- - you cannot do the for orphaned dbo user. EXEC sp_change_users_login 'update_one', '(ORPHANED_USER)' , '(GOOD_USER)' -- Fix dbo if necessary exec sp_changedbowner 'sa' |
Last Updated on Wednesday, 13 April 2011 10:28 |