Site Search:
Sign in | Join | Help
4Penny.net

SQL Server (T-SQL)

Comments and notes on SQL Server 2000, 2005, and T-SQL

SQL Server Orphaned Users

When restoring a SQL Server backup, the users that are restored in the database are not the same as the users that were created at the server level, even though they may share the same name.  This creates a problem with websites/users/etc that try and log into these databases.  Because the accounts aren't the same, the login is rejected.

There are several ways to fix this problem.  Sometimes it is easiest to just delete the account out of the database and recreate the account at the server level.  This only works when the user account in question hasn't created any of the objects in the database.

If the account has created objects in the database, then create a new server login with the same name as the database login.  Run the stored procedure:

sp_change_users_login 'update_one', 'username', 'username'

This remaps the accounts to be the same based off of the name.

 For more info, see:

http://support.microsoft.com/kb/274188

 

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.