server| Error
Error 21002:[SQL-DMO] user "xxx" already exists, how to solve! URGENT!!!!
Deletes xxx
Update in the sysusers of the database:
Corresponds to the orphaned user of the logged-on user and the database
In fact, we have created the same name of the database after the user, the table in the database we can not use the same because the SID is different, is the system login table and database user table in the same user name, only Sid field, database or previous old system SID value , so we're going to map it to our new database, which relies on SIDS to identify users.
Here you can use stored procedure sp_change_users_login. It has three kinds of movements, namely Report,update_one and Auto_Fix.
Run sp_change_users_login ' ", the system lists the number of orphaned users for the current database.
We just need to select the current database as TestDB and then run
sp_ Change_users_login ' Update_One ', ' Test ', ' Test '
system will prompt to fix an orphaned user.
If you do not have a logon user to create test, you can also use
sp_change_users_login ' auto_fix ', ' Test ', NULL, ' Testpassword '
To create a login user named Test with the password Testpassword the user corresponding to it.
Okay, here. Typically, database object access issues have been resolved. If there are multiple databases with the same user's datasheet, just select a different database and execute the Update_One.