Error 1813 when executing sp_attach_db in QA

Source: Internet
Author: User

Execute sp_attach_db or sp_attach_single_file_db in QA. The following message is displayed: Error 1813: failed to open the new database 'dbname'. create database will be terminated. Device activation error. The physical file name 'd: SQL servermssqldatadbname _ log. ldf' may be incorrect!

Then I came to baidu to find the relevant method, which is good and solved.

Follow these steps:

1. Create a database with the same name. 2. Stop the SQL Server service. (do not detach the database)

3. overwrite the new database with the data file of the original database. 4. Restart the sqlserver service.

5. When you open the Enterprise Manager, there will be doubts. Ignore it first and execute the following statement (note that you must modify the database name). 6. After the statement is complete, you can access the data in the database. At this time, the database itself generally has a problem. The solution is: use the database script to create a new database, and then import the data through DTS.

Use master

Go

Sp_configure 'Allow updates', 1 reconfigure with override

Go

Update sysdatabases set status = 32768 where name = 'suspicious database name'

Go

Sp_dboption 'questionable database name', 'single user', 'true'

Go

Dbcc checkdb ('questionable database name ')

Go

Update sysdatabases set status = 28 where name = 'questionable database name'

Go

Sp_configure 'Allow updates', 0 reconfigure with override

Go

Sp_dboption 'questionable database name', 'single user', 'false'

Go
 

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.