SQL Server Error 1467: Fix a Suspect Database
In this article
SQL Server error 1467 means the database you are trying to open is marked as emergency or suspect, so SQL Server has taken it offline and refuses normal access. The fix is to confirm the database is genuinely suspect, take a backup of the files if you can, put the database into EMERGENCY mode, run a consistency check, repair what is repairable, and then bring it back online. If the damage is too severe, restore from a known-good backup instead. You need sysadmin rights on the SQL Server instance and, ideally, a recent backup before you start.
What You'll Need
- Sysadmin (or db_owner with the ability to run DBCC) access to the SQL Server instance.
- SQL Server Management Studio (SSMS) or sqlcmd connected to the instance.
- A recent, verified backup of the database, if one exists.
- Enough free disk space for a repair and for any backup you take first.
- The database name and, if possible, the original error message from the SQL Server error log.
Step-by-Step
- Confirm the state. In SSMS, connect to the instance, expand Databases, and look for the database shown with a suspect or offline label. In a query window run
SELECT name, state_desc FROM sys.databases WHERE name = 'YourDB';and note whether it says SUSPECT, EMERGENCY, or RECOVERY_PENDING. - Read the error log. Open Object Explorer > Management > SQL Server Logs, or run
sp_readerrorlog, and find the entries around the failure. This tells you whether the problem is a missing file, a corrupted page, or an I/O error, which changes how you proceed. - Stop and copy the files. Before changing anything, copy the .mdf and .ldf files to another location if the disk allows it. This is your fallback if a repair makes things worse.
- Take the database out of suspect state. Run
ALTER DATABASE YourDB SET EMERGENCY;thenALTER DATABASE YourDB SET SINGLE_USER;so nobody else connects while you work. - Run a consistency check. Execute
DBCC CHECKDB ('YourDB') WITH NO_INFOMSGS;and read the output carefully. It lists the corrupt pages and recommends a repair level. - Try a repair. If CHECKDB reports repairable errors, run
DBCC CHECKDB ('YourDB', REPAIR_REBUILD) WITH NO_INFOMSGS;. Use REPAIR_ALLOW_DATA_LOSS only when REPAIR_REBUILD cannot fix the problem and you accept that some rows may be removed; take a backup first if at all possible. - Return the database to normal. Run
ALTER DATABASE YourDB SET MULTI_USER;and thenALTER DATABASE YourDB SET ONLINE;. Check that applications can connect and run a short query against a key table. - If repair fails, restore. Restore the most recent good backup over the database, then apply any transaction log backups you have. If you have no backup, the remaining option is to extract what data you can from the emergency-mode database into a new one.
Common Mistakes
- Running REPAIR_ALLOW_DATA_LOSS as a first step. It can delete rows and pages, so it should be a last resort after REPAIR_REBUILD and only with a backup in hand.
- Leaving the database in SINGLE_USER or EMERGENCY mode after the fix, which blocks normal connections.
- Skipping the copy of the .mdf and .ldf files, then having no way back if a repair goes wrong.
- Assuming the error is always corruption. A missing or moved data file, a permissions problem, or a full disk can also put a database into suspect state.
- Restarting the SQL Server service repeatedly without reading the error log, which hides the real cause.
Tips
- Run DBCC CHECKDB regularly on healthy databases so you catch corruption early, before it becomes a suspect database.
- Keep the database and log files on reliable storage and monitor disk space; running out of space is a common trigger.
- Test your restores periodically. A backup you have never restored is not a proven backup.
- Note the exact state (SUSPECT vs EMERGENCY) before you start, because the commands differ slightly depending on what you find.
Troubleshooting
If ALTER DATABASE ... SET EMERGENCY fails, check that you are connected as sysadmin and that no other session holds the database. If DBCC CHECKDB reports errors it cannot repair, restore from backup. If the error log points to a missing file, correct the file path with ALTER DATABASE YourDB MODIFY FILE before bringing it online. If the database comes online but queries fail, run CHECKDB again and review the application error log. When a repair would delete data you cannot lose, stop and involve a database recovery specialist rather than forcing REPAIR_ALLOW_DATA_LOSS.
Frequently Asked Questions
What causes SQL Server error 1467?
It is raised when the database is marked suspect or emergency, usually after corruption, a missing or inaccessible data file, an I/O error, or a disk-full condition.
Can I fix it without a backup?
Sometimes. EMERGENCY mode plus DBCC CHECKDB with REPAIR_REBUILD can recover many cases. If repair needs REPAIR_ALLOW_DATA_LOSS, some data may be lost, so extract what you can first.
Is REPAIR_ALLOW_DATA_LOSS safe?
No. It can remove corrupted pages and the rows on them. Use it only when other repairs fail and you accept possible data loss.
Why is the database still suspect after a restart?
A restart does not clear suspect state by itself. You must set the database to EMERGENCY, repair it, and then set it ONLINE.
Should I detach and reattach the database?
Only as a last resort and only with file copies in hand. Detaching a suspect database can make recovery harder if the files are damaged.
How do I prevent this in future?
Run regular consistency checks, keep tested backups, monitor disk space, and use reliable storage for database files.