Ms SQL Server Error 21002: [SQL-DMO] user "XXX" already exists

Source: Internet
Author: User
Error 21002: [SQL-DMO] user "XXX" already exists, how to solve it! Urgent !!!!

Delete XXX from database sysusers

Update:

Correspond login users to isolated database users
In fact, after we have created a database login user with the same name, we still cannot use the tables in the database because of the different Sid, that is, the user names in the system login table are the same as those in the Database User table, only the SID field is used. The SID value of the old system is used in the database. Therefore, we need to map it to the new one. The database uses the SID to identify users.
The stored procedure sp_change_users_login can be used here. It has three actions: Report, update_one, and auto_fix.
Run sp_change_users_login 'report'. The system lists the number of isolated users of the current database.
We only need to select the current database as testdb and then run
Sp_change_users_login 'Update _ one', 'test', 'test'
The system prompts you to fix an isolated user.
You can also use
Sp_change_users_login 'Auto _ fix', 'test', null, 'testpassword'
Create a user with the logon username "test" and the password "testpassword.

Now, the problem of accessing database objects has been solved. If multiple databases have data tables of the same user, you only need to select different databases and execute the update_one operation.

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.