Reattach user to database

After a backup restore in SQL Server a user can get disconnected from the database.
When you try to restore this you get the error “User, Group or Role ‘<username>’ already exists in the current database”. This problem can be fixed by running the following stored procedure.

EXEC sp_change_users_login 'Auto_Fix', '<username>', NULL

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>