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