SQL Server Database Going into 'Suspect' Mode
A production database becoming inaccessible and going 'Suspect' after a sudden power outage.
Problem
After a sudden power outage, the production database started showing as 'Suspect' in SQL Server Management Studio; the application couldn't connect to it at all.
Cause
The transaction log was left in an inconsistent state during the outage, and SQL Server couldn't complete the recovery process when it restarted.
Solution
The database was first set to EMERGENCY mode and DBCC CHECKDB was run to assess the damage. Rather than risking data loss with REPAIR_ALLOW_DATA_LOSS as a last resort, a restore from the latest full backup was preferred to preserve data integrity. Afterwards, UPS monitoring and a proper shutdown procedure for SQL Server were put in place.
ALTER DATABASE MyDb SET EMERGENCY;
DBCC CHECKDB (MyDb) WITH NO_INFOMSGS;
ALTER DATABASE MyDb SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
-- Tercih edilen yol: guncel yedekten restore
RESTORE DATABASE MyDb FROM DISK = 'D:\Backups\MyDb_Full.bak' WITH REPLACE;
ALTER DATABASE MyDb SET MULTI_USER;