Monday, July 21, 2008

Fixing users in SQL2005 after restoring a DB

After you restore a database in SQL Server 2005 to a different server, you will need to fix the login associated with the users in the database this can be done by using the following stored procedure:

exec sp_change_users_login 'AUTO_FIX','UserName'

If you don't do this you will get an error while trying to login as the user. This needs to be done for each user in the database.

1 comment:

.Net said...

Hey Berke,

This solution worked well for me man.. you are my hero.. I have been working hard all the day to figure out why this is happening.. your solution have worked it out perfectly.

Really Helpful, Thanks Aloot man