What's Actually Happening Here
SQL Server marks a database as suspect when it can't recover it during startup. This usually means corruption in the transaction log, a failed I/O operation, or a power failure that left the database in an inconsistent state. You'll see the database in SSMS with (Suspect) next to its name, and queries will return error 945: "Database 'yourdb' cannot be opened due to inaccessible files or insufficient memory or disk space."
Here's the thing: don't panic. In most cases, you can fix this without restoring from backup. But you need to understand the trade-offs. Each fix takes more time but also gives you more options. Start with the simplest, and only move forward if it fails.
Fix 1: Quick Reset with sp_resetstatus (30 seconds)
This is the fastest trick. It just clears the suspect flag and tells SQL Server to try again. It works about 20-30% of the time, usually when the server had a temporary glitch or a disk path issue that's since been resolved.
Steps
- Open SQL Server Management Studio (SSMS).
- Connect to the instance. You'll need sysadmin rights.
- Open a new query window and run:
EXEC sp_resetstatus 'YourDatabaseName';
- If it says the database is not suspect, you're done. If it gives an error like "Cannot use sp_resetstatus because the database is in a state that prevents recovery," move to Fix 2.
Why this works: The stored procedure sp_resetstatus directly updates the sys.databases system table to flip the suspect flag from 1 to 0. It doesn't fix corruption—it just changes the flag so SQL Server retries recovery. If the actual problem was transient (like a locked file during a backup), the second attempt often succeeds.
When to skip this: If you know the disk is failing or the log file is physically corrupt, don't bother. Go straight to Fix 3.
Fix 2: Single User Mode Recovery (5 minutes)
This fix puts the database in single user mode, then sets it to emergency mode, then runs recovery manually. It works for about 60% of cases where Fix 1 failed. You'll need to be comfortable with T-SQL.
Steps
- Open SSMS as administrator. Right-click SSMS and choose "Run as administrator."
- Connect to the instance with sysadmin credentials.
- Run these commands one by one:
ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE YourDatabaseName SET EMERGENCY;
DBCC CHECKDB (YourDatabaseName, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS;
- When DBCC CHECKDB finishes, run:
ALTER DATABASE YourDatabaseName SET MULTI_USER;
- Check if the database is now online. If it is, run a backup immediately.
What's the deal with REPAIR_ALLOW_DATA_LOSS? This flag tells SQL Server to delete corrupt pages and rebuild indexes without them. You will lose some data—usually a few rows or pages that were corrupted. That's why the name is honest: it allows data loss. But it's better than losing the whole database. The alternative REPAIR_REBUILD only fixes non-corrupt structures and usually fails on suspect databases.
Gotcha: If the database is too big (say 1 TB+), this can take 15-30 minutes. Don't run it during peak hours.
Fix 3: Full Recovery via Backup/Log Export (15+ minutes)
This is your nuclear option. Use it when Fix 2 fails with errors like "repair allowed data loss but still can't recover." You'll need to restore from a recent backup, then apply transaction logs to minimize data loss.
Steps
- If you have a full backup from last night, restore it to a new database name (like YourDatabaseName_Recovered):
RESTORE DATABASE YourDatabaseName_Recovered
FROM DISK = 'C:\Backups\YourDatabaseName_Full.bak'
WITH REPLACE, NORECOVERY;
- Apply any differential backups:
RESTORE DATABASE YourDatabaseName_Recovered
FROM DISK = 'C:\Backups\YourDatabaseName_Diff.bak'
WITH NORECOVERY;
- Apply the latest transaction log backup. If the log is still available as a live .ldf file, you can try a tail-log backup first:
BACKUP LOG YourDatabaseName
TO DISK = 'C:\Backups\YourDatabaseName_LogTail.bak'
WITH CONTINUE_AFTER_ERROR, NO_TRUNCATE;
- Restore that log:
RESTORE LOG YourDatabaseName_Recovered
FROM DISK = 'C:\Backups\YourDatabaseName_LogTail.bak'
WITH RECOVERY;
- Now the recovered database is online. Copy the data you need using
INSERT INTO ... SELECTor a linked server query.
Why this takes 15+ minutes: Restoring a big database is I/O bound. Also, you'll need to carefully order your backup files. If you don't have a backup, you're stuck with Fix 2 or calling a specialist.
When to Call a DBA (or a Specialist)
If none of these work, stop. You might have hardware failure on the storage array, a corrupt transaction log that's beyond repair, or a SQL Server version issue (e.g., mixing 2012 with 2017). At this point, you need someone who can mount the .mdf file on a different server or use third-party recovery tools. Personally, I've seen this happen three times on SQL Server 2016 with faulty SSDs—new drives fixed the root cause.
Preventing It Next Time
- Enable instant file initialization. It reduces corruption risk during log growth.
- Check your disk health. Run
chkdskor check SMART status monthly. - Schedule regular DBCC CHECKDB with
WITH DATA_PURITYto catch corruption early. - Use a full recovery model with frequent log backups (every 15 minutes for busy databases).
That's it. Start with Fix 1, work your way up. Most people solve it at Fix 2.