SQL Server error 952 means the database you are trying to use is mid-way through a state change — typically a restore, recovery, or file move — and SQL Server will not let you query or modify it until that operation finishes. The fix is almost never a command; it is to find out which operation is running, wait for it to complete (or stop it cleanly if it is stuck), and only then run your statement again. You need a login with at least VIEW SERVER STATE (or sysadmin) to diagnose it, and you should avoid restarting the SQL Server service until you have checked what is actually happening.
What You'll Need
- A login with permission to query system views — db_datareader on master is not enough; you need VIEW SERVER STATE, or membership in sysadmin or the server-level processadmin role for the kill step.
- SQL Server Management Studio (SSMS) or Azure Data Studio connected to the instance, or sqlcmd if you prefer a terminal.
- The exact database name from the error message.
- Patience and a maintenance window: some transitions (a large restore, a long rollback) can run for hours, and interrupting them can make things worse.
Step-by-Step
- Read the full error text. Error 952 usually arrives with a state number such as 1 (restoring), 2 (recovering), 3 (recovery pending), 4 (suspect), 5 (offline), 6 (offline for snapshot), 7 (online pending), or 8 (restoring from snapshot). The state tells you what phase the database is in. Note it before doing anything else.
- Identify the database and confirm its current state. In SSMS, run
SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabase';. A state_desc of RESTORING, RECOVERING, RECOVERY_PENDING, SUSPECT, OFFLINE, or ONLINE_PENDING confirms the transition. If the query itself fails, you are connected to the wrong instance or lack permission. - Look for the session doing the work. Run
SELECT session_id, command, status, percent_complete, start_time, estimated_completion_time FROM sys.dm_exec_requests WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE','DBCC','ROLLBACK','KILLED/ROLLBACK');. A row with a rising percent_complete means the operation is healthy — wait it out. A row stuck at the same percent for a long time, or a status of KILLED/ROLLBACK, means you have a rollback in progress that must finish before the database can come online. - Check for an active restore or file move. If the state is RESTORING, someone (or a scheduled job) is restoring over the database. Confirm with the operations team or check SQL Server Agent job history. Do not attempt to bring the database online with
RESTORE DATABASE ... WITH RECOVERYunless you are certain the restore is complete; doing so mid-restore corrupts the restore chain. - Wait for a normal transition to finish. Recovery after a restart, an online index rebuild, or a file move can take minutes to hours depending on database size and log volume. Monitor with the query in step 3 and check the SQL Server error log (
EXEC sp_readerrorlog;) for progress messages. When the state returns to ONLINE, rerun your original statement. - If the operation is genuinely stuck, stop it cleanly. For a restore that is hung, issue
RESTORE DATABASE YourDatabase WITH RECOVERY;only after confirming the backup finished. For a session that is blocking recovery, useKILL <session_id>;with the session_id from step 3 — but be aware that killing a restore or rollback forces SQL Server to undo the work, which can take as long as the original operation. Never restart the SQL Server service while a rollback is running unless you have no other option; the rollback will simply start again on startup. - Bring an offline database back online. If state_desc is OFFLINE and no operation is running, run
ALTER DATABASE YourDatabase SET ONLINE;. This fails if files are missing or permissions are wrong — check the error log for the specific file path. If the database is SUSPECT, do not attempt SET ONLINE; move to the troubleshooting section. - Verify and retry. Once state_desc reads ONLINE, run a simple
SELECT COUNT(*) FROM sys.tables;against the database, then rerun the statement that produced error 952. If the error returns, capture the state number again — a repeating 952 with the same state usually means the transition is failing and restarting, not completing.
Common Mistakes
- Restarting the SQL Server service as a first move. A restart does not cancel a rollback; it queues it to run again at startup, often making the outage longer. Diagnose first.
- Running
RESTORE ... WITH RECOVERYon a database that is still restoring. This can leave the database unusable and force a full restore from scratch. - Assuming error 952 is a permissions problem. It is a state problem. Granting more rights will not help while the database is in transition.
- Ignoring the state number. State 1 (restoring) and state 4 (suspect) need completely different responses; treating them the same wastes time.
- Killing a rollback session repeatedly. Each kill restarts the undo work. Kill once and let it finish.
Tips
- Schedule restores and file moves in maintenance windows so users never hit a transition.
- Use
WITH NORECOVERYdeliberately when chaining restores, and only the final restore should useWITH RECOVERY. - Keep an eye on
sys.dm_exec_requests.percent_complete— it is the most reliable progress indicator for restores and rollbacks. - For very large databases, test the restore duration on a copy so you can plan the outage realistically.
- Alert on state_desc changes so you learn about transitions before users report errors.
Troubleshooting
The database is stuck in RECOVERY_PENDING. This usually means a file is missing or inaccessible. Check the SQL Server error log for the exact path and error, restore file permissions for the SQL Server service account, and then run ALTER DATABASE YourDatabase SET ONLINE; again.
The database is SUSPECT. Do not run SET ONLINE. Take a tail-log backup if the database is in FULL recovery and the log is intact, then restore from your last good backup. If you are not confident, involve a DBA — forcing a suspect database online can cause data loss.
The rollback never finishes. Check sys.dm_exec_requests for the KILLED/ROLLBACK status and the wait type. If progress is genuinely zero for hours and the instance is unusable, a service restart will resume the rollback on startup — plan for the same duration again. There is no supported way to skip the undo phase.
Error 952 appears only for one application. The application may be reconnecting during a brief transition (for example a nightly restore). Add retry logic in the app, or move the restore out of business hours.
You cannot query sys.databases at all. You are probably connected to a different instance or lack VIEW SERVER STATE. Ask an admin to grant it, or run the queries from an account that already has it.
Frequently Asked Questions
What does "database is in transition" actually mean?
SQL Server is changing the database's state — restoring, recovering, going offline, or coming online — and refuses new connections until the change completes. It is a safety lock, not corruption by itself.
Can I force the database online?
Only when no restore or rollback is running and the state is OFFLINE. Use ALTER DATABASE ... SET ONLINE;. For RESTORING or SUSPECT states, forcing it can cause data loss or break the restore chain.
Will restarting SQL Server fix error 952?
Usually not. A restart interrupts active sessions but resumes recovery or rollback at startup, so the database stays in transition and the outage gets longer.
How long can a transition take?
It depends on database size, log volume, and disk speed. A small database recovers in seconds; a multi-terabyte restore or rollback can take hours. Watch percent_complete rather than guessing.
Is error 952 dangerous?
The error itself is not — it is a status message. The danger is in how you respond: forcing recovery or repeatedly killing rollback sessions is what causes damage.
Does this happen on Azure SQL Database too?
Azure SQL Database manages transitions internally and does not expose the same ALTER DATABASE SET ONLINE control. If you see a transition-related error there, wait and retry, or open a support request through the Azure portal.