SQL Server Error 15023: a user or role already exists in the current database

Source: Internet
Author: User

Solution to SQL Server 15023 Error

First introduceSQLServerLogin"And"User"Difference

"Login"Used for user authentication, while the Database"User"Account is used for database access and permission verification. Logon is associated with the user through the security identifier (SID. When the database is restored to another server, the database contains a group of users and permissions, but the corresponding logon or logon users may not be the same. This situation is called "isolated user ". In this case, you cannot create a new login or grant the "user" permission of the corresponding database to the login with the same name, because sqlserver will report "error 15023: A user or role already exists in the current database. To solve this problem, you need to call the system stored procedure sp_change_users_login. The usage is as follows:

-- Log in with the SA account first

Use netzs -- use the database gosp_change_users_login 'Update _ one', 'username', 'login name', for example, sp_change_users_login 'Update _ one', 'xjiang ', 'yjsy312'

Netzs is a database with isolated users. update_one is a stored procedure parameter, indicating that only one user is processed. The previous xjiang is a "user", and the last xjiang is a "login ", the preceding SQL statement re-connects "xjiang", the server logon user, and "xjiang", the netzs database user. In this way, the database can be used normally.

From: http://cndongtian.blog.163.com/blog/static/17552338720101511540698/

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.