Error 21002:[SQL-DMO] user "xxx" already exists

Source: Internet
Author: User

Original: Error 21002:[SQL-DMO] user "xxx" already exists

Reprinted from: http://topic.csdn.net/u/20120829/09/faf381b6-d4e9-4f97-a21f-d1adfd43fbe4.html?seed=1190913404&r= 79566866#r_79566866

MSSQL2000 when you migrate a database or restore a database, create a new user name or specify a database logon user error message: "Error 21002:[SQL-DMO" user "xxx" already exists "


Cause:
This is what we often call "orphaned users", the so-called orphaned accounts, that is, the account of a database only the user name and no login, such users in the user library sysusers system tables exist, and in the master database syslogins there is no corresponding record.
orphaned accounts are typically produced in two ways:
1. Restore the backed-up database to another machine;
2. After reloading the system or SQL Server, only the user library is restored

Workaround:
The workaround is to use sp_change_users_login to fix it.
There are three ways to use sp_change_users_login

Repair Method:
Step 1:
Open Query Analyzer and run the following command into the corresponding database
exec sp_change_users_login ' report '
List orphaned users of the current database

Step 2:
exec sp_change_users_login ' auto_fix ', ' User name '
you can automatically add a login with the same name that corresponds to the user name to syslogins

Step 3:
exec sp_change_users_login ' update_one ', ' User name ', ' Login name '
maps the user name to the specified login name.

after running the above three commands, you can try again, the user will be able to log in normally

Error 21002:[SQL-DMO] user "xxx" already exists

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.