SQL Server Log Explorer
Restore Data

SQL Server Database in Emergency Mode: What It Means and How to Fix It

Andrew Jackson Modified: 7 Minutes Reading
On this page

Quick Answer

EMERGENCY mode gives a sysadmin access to a damaged database and blocks every write. Microsoft marks the database READ_ONLY and switches logging off. In our test a SELECT returned all 3 rows and an INSERT failed with error 3908. The statement ALTER DATABASE YourDB SET ONLINE ended the state and the database accepted writes again. A repair with REPAIR_ALLOW_DATA_LOSS failed with error 7919 until we set SINGLE_USER mode. Copy your MDF and LDF files before any repair because that option can delete data.

Object Explorer shows your database as EMERGENCY and your application cannot save a single row. You set that state on purpose or a repair guide told you to.

This guide shows what the state allows, the exact errors we got on SQL Server 2022 and three ways out of it. You will know in a few minutes whether to set the database online, repair it or export its data.

What Does Emergency Mode Mean for a SQL Server Database?

Microsoft states only a member of the sysadmin fixed server role can set a database to EMERGENCY and that access is limited to sysadmin members. It also states the database is marked READ_ONLY and logging is disabled. Microsoft names troubleshooting as the main purpose.

We created a healthy database with 3 rows, set it to EMERGENCY and tried six actions.

Action Result on our test instance
SELECT from a table Worked and returned 3 rows
INSERT a row Failed with error 3908, Could not run BEGIN TRANSACTION in database because the database is in emergency mode or is damaged and must be restarted
DBCC CHECKDB without a repair option Finished with no errors
DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS in multi user mode Failed with error 7919, Repair statement not processed. Database needs to be in single user mode
ALTER DATABASE SET EMERGENCY on a database in RESTORING state Failed with error 5069, ALTER DATABASE statement failed
ALTER DATABASE SET ONLINE Database returned to ONLINE and an INSERT worked

Check Updateability and Not is_read_only

In our test sys.databases showed state_desc EMERGENCY but the is_read_only column stayed 0 and user_access_desc stayed MULTI_USER. The property DATABASEPROPERTYEX('YourDB','Updateability') returned READ_ONLY. Use the state and that property to confirm writes are blocked.

Why Is Your Database in Emergency Mode?

Microsoft describes EMERGENCY as a state a user sets. You land in it in one of four situations.

Situation State you see Next step
You executed SET EMERGENCY to troubleshoot EMERGENCY Use Method #1 when the data is fine or Method #2 when CHECKDB finds errors
A guide told you to set it after a SUSPECT flag EMERGENCY Start with our guide on the reasons for a suspect database
Database shows RECOVERY PENDING RECOVERY PENDING Follow our steps to fix the recovery pending state
Database shows RESTORING RESTORING EMERGENCY is not possible and returns error 5069. Finish the restore with our guide on a database stuck in the restoring state

What Does the Repair Need on Your Server?

System Specifications

Component Requirement
Permission to set the state Member of the sysadmin fixed server role
Access while in the state Limited to sysadmin members according to Microsoft
Disk space Free space equal to your MDF and LDF files for a safe copy before the repair
PC for the recovery software Windows up to Windows 10 with 512 MB of RAM and 50 MB of free disk space

Software Specifications

Item Requirement
Repair statement DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS in SINGLE_USER mode
Exit statement ALTER DATABASE ... SET ONLINE
Recovery software Lists SQL Server 2019 and earlier
Tested on SQL Server 2022 (RTM CU26) Express on Linux

How Do You Fix a SQL Server Database in Emergency Mode?

Method #1: Set the Database Online (Free, Data Is Fine)

Use this method when you set the state for a check and the check found nothing wrong. Execute a plain CHECKDB first because it works in the EMERGENCY state.

DBCC CHECKDB (N'YourDB') WITH NO_INFOMSGS;
ALTER DATABASE YourDB SET ONLINE;
SELECT name, state_desc FROM sys.databases WHERE name = N'YourDB';

Our test returned ONLINE and MULTI_USER. An INSERT worked at once and the table then had 4 rows.

Any message from CHECKDB means damage. Do not set the database online and move on. Use Method #2 or Method #3.

Method #2: Repair With CHECKDB in Single User Mode (Free, Can Delete Data)

Use this method when you have no usable backup and CHECKDB reported errors. Microsoft recommends a restore from the last known good backup first and calls the repair options a last resort.

ALTER DATABASE YourDB SET EMERGENCY;
ALTER DATABASE YourDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DBCC CHECKDB (N'YourDB', REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;
ALTER DATABASE YourDB SET MULTI_USER;
  • Skip the first statement when the database is already in EMERGENCY.
  • Set SINGLE_USER mode first or CHECKDB returns error 7919, as our test showed.
  • Check the last line of the CHECKDB output for the count of allocation errors and consistency errors.
  • Set MULTI_USER when the repair ends.

Our healthy test database showed ONLINE after the repair while it was still in SINGLE_USER mode. The recovery model stayed FULL and CHECKDB found 0 allocation errors and 0 consistency errors.

Microsoft states CHECKDB rebuilds the transaction log when recovery fails because of log corruption and that the rebuild can lose transactional consistency. Treat a repaired database as a new starting point and take a full backup. In our log backup chain test a log backup returned error 4214 when no current backup existed.

Heads Up

Microsoft states REPAIR_ALLOW_DATA_LOSS can lose more data than a restore from the last known good backup. Copy the MDF and LDF files before you execute it.

Method #3: Export the Data With SQL Recovery Utility (Paid, No Repair Needed)

Use this method when CHECKDB reports damage and the repair would delete rows you need. SQL Recovery Utility opens the MDF file without a live SQL Server and previews the tables it finds before you export.

  • Click Open and select the .mdf file of the database.
  • Select a scan mode and choose the SQL Server version of the database.
  • Check the preview for your tables and records.
  • Select SQL Server Database, enter the login details and select a new or an existing database.
  • Select With schema and data and click Export.

Open button of the recovery software for a database file
Quick Scan and Advanced Scan options of the recovery software
Preview of recovered database objects in the recovery software

SQL Recovery Utility

Scan an MDF file and export recovered tables and records.

Heads Up

Scan a copy of the MDF file and work on the copy only. Store the original elsewhere untouched until you check the exported data.

What Should You Check Before You Repair?

  • Copy the MDF and LDF files first. The repair is the one step you cannot undo.
  • Execute a plain CHECKDB. It works in EMERGENCY mode, as our test showed, and tells you how much damage exists before you accept data loss.
  • Look for a backup. Microsoft names a restore from the last known good backup as the primary method. Our guide on how to restore a full database backup lists the steps.
  • Warn the application owners. SINGLE_USER mode with ROLLBACK IMMEDIATE disconnects every session.

FAQs

Can You Write to a Database in Emergency Mode?

No. Microsoft marks the database READ_ONLY. Our INSERT failed with error 3908 while a SELECT worked.

How Do You Take a Database Out of Emergency Mode?

Execute ALTER DATABASE YourDB SET ONLINE. Our test returned ONLINE and accepted a new row. Repair the database first when CHECKDB reports errors.

Why Does CHECKDB Return Error 7919 in Emergency Mode?

The repair options need SINGLE_USER mode. Our repair failed with error 7919 in multi user mode and finished after we set SINGLE_USER.

Can You Set a Restoring Database to Emergency Mode?

No. Our statement failed with error 5069. Finish or recover the restore first.

Does Emergency Mode Delete Data?

No. Our 3 rows were still there after the state and a fourth insert worked after SET ONLINE. Only a repair option like REPAIR_ALLOW_DATA_LOSS can delete data.

Who Can Open a Database in Emergency Mode?

Microsoft states access is limited to members of the sysadmin fixed server role.

About this guide

We checked this guide against Microsoft documentation on 3 Dec 2026. We executed the statements of the first table and the repair and online statements of Method #1 and Method #2 on SQL Server 2022 (RTM CU26) Express on Linux.

Microsoft documents the states on its database states page and the repair options on its DBCC CHECKDB page.