A SQL Server database stays in "restoring" state when the server believes a restore is still in progress—usually because a WITH NORECOVERY restore or a full-log restore sequence was never finished with WITH RECOVERY. The fix is to complete that restore chain with the final RESTORE ... WITH RECOVERY, or, if no further backups will be applied, to force the database online with RESTORE DATABASE ... WITH RECOVERY on its existing files. A database left in "recovery pending" (not "restoring") is a different problem: it needs ALTER DATABASE ... SET ONLINE, and if that fails, log or file damage must be repaired first. Both states are covered below, with the checks and stop conditions that keep you from making things worse.
First, Identify the State You Are Actually In
"Restoration mode" gets used loosely. SQL Server Management Studio (SSMS) displays the state in the database list, and sys.databases reports it authoritatively. Run this before touching anything:
state_desc will show one of four relevant values, and each has a different remedy:
RESTORING — a restore sequence is considered open. Object Explorer shows the database with "(Restoring...)". The normal exit is to apply the remaining log backups and finish with WITH RECOVERY. RECOVERING — SQL Server is actively running recovery on the database at startup or after RESTORE ... WITH RECOVERY. This is transient; a large database can sit here for minutes to hours. Wait before intervening. RECOVERY_PENDING — recovery could not complete, typically because a log file or data file is missing, offline, or damaged. SSMS places this database under a "Recovery Pending" folder. SUSPECT — the database is marked suspect after failed recovery attempts. This is usually a storage or corruption issue, not a restore-sequence issue.
The important distinction: RESTORING is a bookkeeping state you can deliberately close; RECOVERY_PENDING and SUSPECT are failure states that require diagnosis. Treating them as the same thing is the most common way people turn a recoverable database into a lost one.
For the RESTORING state specifically, confirm what the restore history says before issuing anything:
This tells you whether the last operation was a full restore, a differential, or a log restore, and when it happened. If the most recent entry is a log restore, the database is almost certainly waiting for the next log in the chain. That is the outcome the previous administrator intended, and completing the chain is the correct move.
Prerequisites Before You Change Anything
Before running any recovery command, line up four things:
1: Permission. You need sysadmin, dbcreator, or db_owner on the target database; ALTER DATABASE ... SET ONLINE and RESTORE ... WITH RECOVERY both require elevated rights. 2: A known backup position. Know which backup set the database is currently restored through, and whether more log backups exist. Query msdb.dbo.backupset for the same database name to see the available chain and first_lsn/last_lsn values. 3: Free disk and intact files. Check that every data and log file listed in sys.master_files for that database exists at its recorded path and that the volume has free space. A missing file guarantees RECOVERY_PENDING, and forcing recovery will just fail again. 4: A rollback plan. If you force the database online without the full log chain, you accept potential data loss up to the last restored backup. If that loss matters, copy the current data and log files aside first—before any command—so a restore to a different name remains possible.
One more practical point: check that no application, job, or replication agent is retrying connections against the database. Failed connection attempts during recovery clutter the error log and can obscure the actual failure. Disable or pause those jobs during the operation.
Option 1: Finish the Restore Chain (Preferred When Backups Remain)
If log backups exist that you have not yet applied, this is the correct path, and it preserves all recoverable data. The sequence is ordered for a reason: each NORECOVERY restore leaves the database open to the next file, and only the last one may carry RECOVERY.
1: Identify the current last-applied log backup. From the restore history query above, note the most recent restore_date and backup set. 2: List the remaining log backups in LSN order. In msdb.dbo.backupset, filter type = 'L' (log) for the same database and sort by first_lsn. Use RESTORE HEADERONLY FROM DISK = '...' on each file to confirm the backup set contents before restoring. 3: Restore each remaining log with NORECOVERY, in order, using MOVE options if the file layout differs from the original server:
4: Apply the final log (or tail-log backup) with RECOVERY:
If there is no additional log to apply and the chain is already complete—for example, the last operation was a full restore done WITH NORECOVERY and no logs were taken afterward—the finishing command targets the database itself and its existing files rather than a backup device:
This is the documented way to complete a restore that was deliberately left open; it does not re-copy data.
5: Verify. Re-run the sys.databases query. state_desc should read ONLINE. Then run DBCC CHECKDB ([YourDatabaseName]) WITH NO_INFOMSGS; to confirm the database is structurally sound, and check that the application connects.
Success check: the database appears online in SSMS with no "(Restoring...)" suffix, sys.databases.state_desc = 'ONLINE', and a test query against a known table returns expected row counts.
Failure check: if a log restore returns error 4305 ("The log in this backup set begins at LSN ..., which is too recent to apply to the database"), you have a gap—a missing or out-of-order log. Do not skip it. Locate the missing backup or accept point-in-time loss deliberately, then use Option 2.
Option 2: Force the Database Online Without the Full Chain
When the remaining backups are lost, corrupt, or unavailable, and you have decided the data in the database as restored is acceptable, you can close the restore sequence and bring the database online. This is the same RESTORE ... WITH RECOVERY command as above—there is no special "undo restore mode" switch—but here it is used with the explicit acceptance of data loss.
1: Confirm no restore is actively running. Query sys.dm_exec_requests for commands containing RESTORE and check sys.dm_exec_sessions. A concurrent restore will block or corrupt your attempt.
2: Record the current state and file list in case you need to reconstruct the situation:
3: Run the recovery command:
Expect a completion message within seconds for a database that was already fully restored. If it runs for minutes, the database is large or the I/O subsystem is slow; let it finish.
4: Verify and validate. Check state_desc, then run DBCC CHECKDB. Because you skipped part of the log chain, also spot-check recent transactions: compare the maximum values in key tables against what you expect from the last known good backup.
5: Rebuild what was lost. Re-point applications, re-run any idempotent catch-up jobs, and re-establish replication or log shipping if those were in use.
If the command returns an error rather than completing—commonly "The database cannot be recovered because the log was not restored" or a file-access error—the database is not actually in a clean RESTORING state. Move to the failure-state diagnosis below.
When the State Is RECOVERY_PENDING, Not RESTORING
RECOVERY_PENDING means SQL Server tried to bring the database online and could not finish. Forcing WITH RECOVERY will not help; the underlying cause must be fixed. Work through these reversible checks in order:
1: Check file existence and paths. Compare sys.master_files.physical_name against the file system. Restores to a different server often leave paths pointing at directories that do not exist. If files were moved, correct the paths:
For a database that cannot come online at all, ALTER DATABASE ... MODIFY FILE still works as long as the database is not in SUSPECT state.
2: Check drive letters and permissions. A missing volume, a detached LUN, or a service account that lost read/write access to the data directory all produce recovery failures. Confirm the SQL Server service account has Full Control on the folders holding the .mdf, .ndf, and .ldf files.
3: Check free space on the log volume. Recovery may need to grow the transaction log; a full log drive blocks it. Free space and retry.
4: Look at the error log. sys.dm_os_ring_buffers and the SQL Server error log record the precise failure, such as "File ... is missing" or "The log cannot be rebuilt because there were open transactions/users." The wording points at the right fix.
5: Attempt to bring it online:
If this succeeds, run DBCC CHECKDB before returning the database to service. If it fails with the same error, the cause is still present—return to steps 1–4 rather than repeating the command.
6: If the log is missing and you accept the risk, you can rebuild it and force recovery in one step:
This is a last-resort procedure with real data-loss risk. Only use it if the log cannot be recovered and the data value justifies it. If the database is central to production or regulated data, stop here and involve a database professional or your vendor's support before running repair.
How the States Differ, Side by Side
| State | What it means | Typical fix | Data-loss risk |
|---|---|---|---|
| RESTORING | A restore sequence is open; more files may still be applied | Complete the chain with RESTORE ... WITH RECOVERY | None if the full chain exists; up to last backup if forced early |
| RECOVERING | Recovery is actively running | Wait, then check state | None |
| RECOVERY_PENDING | Recovery could not start or finish; files/log problem | Fix paths, space, permissions, then SET ONLINE | Depends on cause; possible if log is rebuilt |
| SUSPECT | Database failed recovery and is marked suspect | Diagnose I/O or corruption; possibly restore from backup | High; restore from backup is often the right route |
The table makes the asymmetry clear: RESTORING is a controllable state where the command sequence is the fix. RECOVERY_PENDING and SUSPECT are symptoms, and the fix is diagnosis, not a magic command.
Common Mistakes and How to Avoid Them
Forcing recovery too early. If you run RESTORE DATABASE ... WITH RECOVERY while the restore chain still has valid logs available, you close the door on those logs permanently. Always check restore history first.
Restoring out of order. Log restores must follow first_lsn order. Skipping a log produces error 4305 or 4326, and the database will refuse to move forward. If you see LSN mismatch errors, list the remaining chain and confirm order before retrying.
Deleting and re-attaching files to "reset" the state. Detaching a database in RESTORING state is not supported, and re-attaching files from a partial restore will either fail or leave you in the same state with extra steps. The state lives in the file headers, not just in metadata, so file operations do not clear it.
Confusing RESTORING with a stuck query. Check sys.dm_exec_requests before concluding a restore is hung. A monitored restore may display no progress for long stretches on a slow disk.
Overlooking tail-log backups. On a production server that was still taking log backups before the restore began, there may be a tail-log backup capturing transactions after the last restored log. Applying it before WITH RECOVERY can recover more than you expect.
What to Expect and When to Stop
Expect the WITH RECOVERY command itself to finish quickly—seconds to minutes—since the data pages were already written by earlier steps. Verification with DBCC CHECKDB can take far longer on large databases; schedule it appropriately rather than concluding the recovery failed because the check is slow.
Stop and bring in a professional when any of these appear:
The error log reports corruption in data or log files, or DBCC CHECKDB returns consistency errors that REPAIR_ALLOW_DATA_LOSS cannot fix without losing critical rows. The log chain is broken and you cannot determine which backups are trustworthy. The database is SUSPECT and a restore from backup is not possible or would lose data you are required to preserve. The restore failure traces to hardware: failing drives, a degraded RAID array, or storage that has dropped offline. Fixing software state on failing hardware invites a second, worse failure.
When a full backup exists and the current state contains no unique data, restoring cleanly from backup is usually safer, faster, and easier to verify than surgery on a broken restore sequence. Keep the old files aside until the clean restore passes DBCC CHECKDB and the application confirms expected data.
FAQ
Can I remove restoration mode with a single command?
Only when the database is in RESTORING state and the files are intact. RESTORE DATABASE [Name] WITH RECOVERY; completes the open restore sequence in one step. It will not fix RECOVERY_PENDING or SUSPECT, and it permanently forgoes any remaining log backups, so confirm the restore history first.
Is detaching or dropping the database a safe shortcut?
No. Detaching a database in RESTORING state is unsupported, and dropping it deletes metadata while leaving files that may be needed for recovery. If you truly want to abandon the database and start over from a backup, restore to a new database name first, verify it, and only then remove the broken one.
Why does the database show "Restoring" but no restore is running?
The state is stored in the database file headers and server metadata, so it persists after the restore process exits. The restore was almost certainly left open with WITH NORECOVERY and never finished. Query msdb.dbo.restorehistory to confirm, then complete the chain.
Does this apply to Azure SQL Database or SQL Server on Linux?
The same concepts apply, but managed platforms differ: Azure SQL Database does not expose RESTORE ... WITH RECOVERY for user databases, so a database stuck in a non-online state there is a support case rather than a T-SQL fix. SQL Server on Linux supports the same RESTORE and ALTER DATABASE commands, though file paths use Linux conventions and directory permissions must be verified for the mssql user.