nav-left cat-right
cat-right

SQL Server: create failed for user/ User, group, or role already exists in the current database

If experiencing the following errors in SQL Server:

Create failed for User ‘xyz’. (Microsoft.SqlServer.Smo)

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

The above error can sometime occur when migrating a SQL Server Database from one staged environment to another. If both those environments have the same users present you can get issues when trying to add users from the new staged environments to the recently restored DB that the users are already present within.

A solution I found is to map the DB users to the accounts already within the DB. This is achieved by using the stored procedure sp_change_users_login

USE AdventureWorks
GO
EXEC sp_change_users_login 'Update_One', 'xyz', 'xyz'
GO

The above will take the specified user {parameter 2} and map to the login user {parameter 3}.
Further information and other actions are available here: http://msdn.microsoft.com/en-us/library/ms174378(v=sql.105).aspx

Note: MSDN state this feature will be removed in a “future version”.

One Response to “SQL Server: create failed for user/ User, group, or role already exists in the current database”

  1. web page says:

    I actually Believe that blog post, “SQL Server: create failed for
    user/ User, group, or role already exists in the current database” was in fact
    just right! I reallycan’t agree with you even more! Finally seems like I personallyfound a blog very well worth browsing. Thank you, Derick

Trackbacks/Pingbacks

  1. How To Fix Microsoft Sql Server Error 15023 in Windows - […] SQL Server: create failed for user/ User, group, or role … – (Microsoft SQL Server, Error: 15023) … user/…

Leave a Reply

Your email address will not be published.