How to resolve Microsoft SQL Server Error 15023 "User already exists"
When you restore a database from backup to your SQL server in test environment, you will try to add Role to a restored database for user. At this time you may get the error message:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo). User, group or role 'UserName' already exists in the current database. (Microsoft SQL Server Error" 15023).
In 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 userName WITH LOGIN = serverlogin