SQL in the event of a sudden power outage or abnormal shutdown, a date file error may occur, causing the database to be unhealthy. The recovery database method is as follows
1. The database service stops backing up the database file, such as a database named Dtms, dtms.mdf back up.
2. Open the database service and create an empty database with the same name as Dtms.
3. Close the database service and overwrite the original dmts.mdf of the backup to the newly created database directory.
4. Execute the following statement under Master
--Modify database for state of emergency
ALTER DATABASE DTMS set EMERGENCY
--Set the database as a single user
ALTER DATABASE Dtms SET single_user
--Repair log files
DBCC CHECKDB (' Dtms ', Repair_allow_data_loss)
DBCC CHECKDB (' Dtms ', repair_rebuild)
--Set the database to multi-user
ALTER DATABASE Dtms SET multi_user
--Place the database online
ALTER DATABASE DTMS set ONLINE
Recovery method for SQL 2005 log corruption