MSSQL ERROR: Create Failed For User ‘UserName’

MSSQL ERROR: Create Failed For User ‘UserName’

When you restore or migrating your MSSQL database from one to another server, below error message may appear:

Create failed for user ‘UserName’. (Microsoft.SqlServer.Smo)

Additional Information:
An exception occurred while executing a Transact-SQL statement or batch.
User, group, or role ‘UserName’ already exists in the current database. (Microsoft SQL Server, Error: 15023)

You can simple to solve the issue by maps an existing user in a database to a MSSQL Server login:

Use DatabaseName
sp_change_users_login ‘update_one’,‘UserName’,‘UserName’

sp_change_users_login ‘update_one’,‘UserName’,‘UserName‘

For more information about this command, click this sp_change_users_login link to refer the documentation from Microsoft.