Symptom: the database log is too large, so the shrink cannot be dropped. So I want to unload the database file, delete the log, and attach it. Attaching failed.
Error message:
Server: Message 1813, level 16, status 2, Row 1
The new database 'metadb' cannot be opened '. Create database will be terminated.
Device activation error. The physical file name 'd: \ metadb. ldf' may be incorrect.
Environment: MSSQL Server 2000 Enterprise Edition
Solution Process:
1. Create a new database newdb
2. Stop the database. Delete the log file of the new database. metadb. MDF overwrites newdb. MDF.
3. Start the database server. The status of the database newdb is "questionable ".
4. allow direct modification to the system directory
Use master
Go
Sp_configure 'Allow updates', 1
Go
Reconfigure with override
Go
Update sysdatabases set status =-32768 where dbid = db_id ('newdb ')
5. Rebuild log
DBCC rebuild_log ('newdb', 'c: \ Program Files \ Microsoft SQL Server \ MSSQL \ data \ newdb_log.ldf ')
6. DBCC check
DBCC checkdb ('newdb ')
7. Set the database to normal
Sp_dboption 'newdb', 'dbo use only', 'false'
8 direct modification to the system directory is not allowed
Sp_configure 'Allow updates', 0
Go
Reconfigure with override
Go