How to fix: User, group, or role '*' already exists in the current database. (Microsoft SQL Server, Error: 15023)

SQL Server 2008

 If you've restored a database onto another server, you may get the following error message when adding user logins to the database:

Create failed for User 'TMS'. (Microsoft.SqlServer.Smo)

User, group, or role 'TMS' already exists in the current database. (Microsoft SQL Server, Error: 15023)

 

To fix this there are two different methods depending on the version of SQL Server you are using. Both of these commands re-map the user's Security Identifier (SID) to match the sql server login's SID.

 

SQL Server 2008 / SQL Server 2008 R2

If you have already created the server login for the user, run this in the database with the login problem. (Change 'user' to be the database username you wish to fix, and 'serverlogin' is the sql server login to map the user to).

 ALTER USER user WITH LOGIN = serverlogin

For full details of the ALTER USER command see MSDN http://msdn.microsoft.com/en-us/library/ms176060.aspx

 

SQL Server 2005 / SQL Server 2000

If you have already created the server login for the user, run this in the database with the login problem. (Change 'user' to be the username you wish to fix).

EXEC sp_change_users_login 'Auto_Fix', 'user'

Note that sp_change_users_login has be deprecated in SQL Server, future versions will require using ALTER USER.

For full details of sp_change_users_login see MSDN http://msdn.microsoft.com/en-us/library/ms174378.aspx

 

 



Share
  • Facebook
  • Google Bookmarks
  • Ask
  • LinkedIn
  • Socialogs
  • Wikio
  • Digg
  • Twitter
  • SlashDot
  • Reddit
  • MySpace
  • Del.icio.us
  • Blogter
  • BlogMemes
  • Yahoo Buzz






How to fix: User, group, or role '*' already exists in the current database. (Microsoft SQL Server, Error: 15023) | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.


Gold Coast Aquarium Maintenance | Gold Coast Marine Fish | Gold Coast Tropical Fish
Jewel Jones - Counselling Service - Penrith, Richmond
 
     
 Copyright © 2017 Julian Kuiters
 All trademarks and copyrights on this page are owned by their respective owners.