When a SQL Server database becomes suspect or corrupted, SQL Server might automatically set it into EMERGENCY mode. This mode allows limited access for troubleshooting and repair. In this article, we’ll explore how to recover a database from EMERGENCY mode safely — using step-by-step SQL commands and Microsoft-approved recovery practices.
🚨 What Is Emergency Mode?
Emergency mode is a special state in SQL Server that allows administrators to access a database marked as corrupt or inaccessible. It’s read-only, single-user, and bypasses the transaction log for emergency repair or data extraction.
Typical reasons your database enters this state include:
Missing or corrupt transaction logs
Hardware failure or disk corruption
Unexpected shutdowns or SQL Server crashes
File system or drive letter changes
🧠 Step-by-Step Guide to Recover a Database from Emergency Mode
🧩 Step 1. Check Database State
Use this command to verify the current state of your database:
SELECT name, state_desc
FROM sys.databases
WHERE name = 'YourDatabaseName';
If the state shows as EMERGENCY or SUSPECT, proceed to recovery.
🧩 Step 2. Set Database to Emergency Mode (Manually)
If SQL Server has not already done this, you can manually put your database into EMERGENCY mode:
ALTER DATABASE YourDatabaseName SET EMERGENCY;
GO
This gives you sysadmin-level access to inspect and fix the database.
🧩 Step 3. Run Consistency Check (DBCC CHECKDB)
Now, check the physical and logical integrity of your database:
DBCC CHECKDB (YourDatabaseName);
GO
If you see errors like “Msg 824, 825, or 826”, it means corruption exists.
🧩 Step 4. Set Database to Single User Mode
Before performing repairs, you must ensure no other connections interfere:
ALTER DATABASE YourDatabaseName SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
🧩 Step 5. Attempt to Repair the Database
There are multiple repair levels; the most commonly used for severe corruption is:
DBCC CHECKDB (YourDatabaseName, REPAIR_ALLOW_DATA_LOSS);
GO
⚠️ Warning: As the name suggests, this may cause some data loss.
Always attempt to restore from backup first if available.
If you have a valid recent backup, do not run this — instead, restore using RESTORE DATABASE.
🧩 Step 6. Set Database Back to Multi-User Mode
Once the repair completes successfully, return the database to normal operation:
ALTER DATABASE YourDatabaseName SET MULTI_USER;
GO
Then, verify the database state again:
SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabaseName';
GO
It should now show as ONLINE.
🧰 Optional: Restore from Backup Instead of Repair
If you maintain regular backups, restoring is the safest route:
RESTORE DATABASE YourDatabaseName
FROM DISK = 'D:\Backups\YourDatabaseName.bak'
WITH REPLACE;
GO
This avoids potential data loss caused by emergency repairs.

Join the conversation! Your thoughts help the community grow.