MS SQL Server error 21002:[SQL-DMO] User xxx already exists

Source: Internet
Author: User
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.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.