Solution to the "invalid object name" problem after restoring the sqlserver Database Backup

Source: Internet
Author: User
Welcome to the Windows community forum and interact with 3 million technical staff. Problem description: After restoring the database backup on the remote server to the local machine, when a user is associated with a logon user (User ing), the following error occurs: "error 15023: a user or role already exists in the current database ":

Welcome to the Windows community forum and interact with 3 million technical staff> enter the Problem description: After restoring the database backup on the remote server to the local machine, when a "login" is associated with a "user" (User ing), an error occurs: "error 15023: a user or role already exists in the current database: in the migration test platform database

Welcome to the Windows community forum and interact with 3 million technicians>

Problem description:

After restoring the database backup on the remote server to the local machine, an error occurs when a "login" is associated with a "user" (User ing:

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

Problem Analysis: During the database migration test platform, after the SQL server running on the two servers migrates the database, A normal user on the source server cannot log on to the target server.

Solution: When the database is restored to another server, the database contains a group of users and permissions, but the associated 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 SQL Server Reports "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:

Use [database name]

Go

Sp_change_users_login 'Update _ one', 'fwg ', 'fwg'

Update_one is a stored procedure parameter, indicating that only one user is processed. The former fwg is a "user" and the latter fwg is a "login ", the preceding SQL statement re-connects the Server login "fwg" to the Database User "fwg" so that the database can be used normally.

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.