Problem scenarios
During SQL Server database migration, after recovering the database backup file on another Server, you need to recreate the user account on the database. When creating a login User, you must authorize the User in User Mapping for the specific database. Because the recovered database contains a User account with the same name, "User, group, or role already exists in the current database "error message. The error details are as follows:
TITLE: Microsoft SQL Server Management Studio
------------------------------
Create failed for User 'testuser'. (Microsoft. SqlServer. Smo)
------------------------------
Additional information:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft. SqlServer. ConnectionInfo)
------------------------------
User, group, or role 'testuser' already exists in the current database. (Microsoft SQL Server, Error: 15023)
Previous solutions
Before creating a user account (or authorization), delete the user account with the same name in the corresponding database.
Latest Solution
Create a user account without authorization, and then associate the account with the corresponding database user using the following SQL statement. This avoids re-authorization.
USE {target database} EXEC sp_change_users_login 'Update _ one', '{existing username of the target database}', '{created username }'
Method Source
SQL Server Forums-How to assign a login to an existing user?