Fix Orphaned Users SQL2008 R2

General pattern for this common problem following a database restore. Note that the syntax has changed from SQL2005.

SQL 2008 R2 Syntax::

USE <database_name>;
GO
sp_change_users_login @Action='Report';
GO
sp_change_users_login @Action='update_one', @UserNamePattern='',
@LoginName='';
GO

SQL 2005 Syntax:


USE <database_name>;
GO
EXEC sp_change_users_login 'Report';
GO
EXEC sp_change_users_login 'Auto_Fix', 'user';
GO

Leave a Reply

Your email address will not be published.

17 − = 8