About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
A database in the RECOVERY PENDING state is not damaged as far as SQL Server knows. Microsoft describes it as a state where SQL Server "has encountered a resource-related error during recovery", where "files might be missing or system resource limitations might be preventing it from starting" (Database states). A common trigger is a data or log file that SQL Server could not open at startup, so the first job is to read the error log, find the operating system error, and fix that. Repair commands are not the first step.
What the error means
Before a database can be used, SQL Server initialises it, opens every file that belongs to it, and then runs recovery. If opening a file fails, the database is left in RECOVERY_PENDING and applications cannot reach it (MSSQLSERVER_17204). If a system database hits the same failure, the whole instance will not start, which is a different and more serious problem.
Recovery Pending is not the same as Suspect. In the Microsoft definitions, Suspect means at least the primary filegroup "is suspect and might be damaged" and "can't be recovered during startup". Recovery Pending is a failure to begin, caused by a resource problem, and the page says the database "isn't damaged". Both states leave the database unavailable and both need action from you. The distinction matters because the fixes differ: a Recovery Pending database needs an environmental fix, while a Suspect one points towards restoring or repair decisions covered in the article on integrity errors.
The file open that fails is reported as error 17204 or 17207 in the SQL Server error log and the Windows Application log (17204, 17207). The message carries the full file path, the file ID and an operating system error number. Microsoft states that this operating system error "is the root cause".
Example (illustrative): after a storage change on server SQL01, the error log shows FileMgr::StartPrimaryDataFiles: Operating system error 2(The system cannot find the file specified.) occurred while creating or opening file 'F:\SQLData\SalesDB.mdf', and SalesDB shows RECOVERY_PENDING. The format follows the example in the 17207 page.
Likely causes
The table maps the operating system error in the message to the cause. The operating system error numbers 2, 3, 5 and 32 are those Microsoft names on the 17204 and 17207 pages.
| Cause | What you see | How to confirm |
|---|---|---|
| File or folder not found (wrong path, missing drive, volume not yet mounted, file deleted) | 17204 or 17207 with "The system cannot find the file specified" (OS error 2 in the 17207 example, error 3 in the 17204 user-action text) | Compare the path in the message with physical_name in sys.master_files, then check the path in Windows |
| Permission denied on the file or folder | OS error 5, "Access is denied" | Check the file's permissions for the SQL Server service group, and the account the service runs as |
| File locked by another process, such as antivirus or a backup agent | OS error 32, "The process cannot access the file because it is being used by another process" | Find the process holding the file with Sysinternals Process Explorer or Handle |
| Resource limit during recovery | Recovery Pending with an error that names a resource rather than a file | Read the full error log entry. Microsoft's page names "system resource limitations" without listing them, so act on what the message names |
| Files genuinely gone | OS error 2 or 3 and the file is not anywhere on the server | Confirm the file is absent, then plan a restore |
Two further points come from the same pages. Moving or restoring files can change which account touches them: "the account that is used for impersonation and accessing the database file may vary" by operation, and Microsoft suggests Process Monitor to see which account is denied. And a virus scanner that opens a database file as SQL Server opens the database can lead to the database being marked suspect (Configure antivirus software to work with SQL Server). A scanner can therefore produce either state.
Prove the cause before changing anything
All of the following are read-only. They follow the Microsoft pages cited and have not been run or lab-tested.
- Confirm the state.
state_descinsys.databasesis the documented place to read it.
SELECT name, state_desc FROM sys.databases;
- List the files the instance expects, and their states. This is the query from the Microsoft page on moving user databases, widened to show all databases. Microsoft notes that if a database is offline, the state of its files can still be viewed from
sys.master_files(File States).
SELECT DB_NAME(database_id) AS database_name, name,
physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'<database_name>');
- Read the SQL Server error log. In SQL Server Management Studio, expand Management, right-click SQL Server Logs, choose View, then SQL Server Log (View the SQL Server error log). Look for 17204, 17207 or 5120 near the time of the last start or the last attempt to bring the database online. Note the path and the operating system error.
- Decode a bare error number. If the message has a code and no description, the 17204 page suggests
net helpmsg <error code>from an operating system shell. - Check the same path in Windows. Is the drive present, is the folder there, is the file there?
- Find who holds the file (error 32): use Process Explorer or Handle, the tools Microsoft names.
- See who is denied (error 5): run Process Monitor and look for
ACCESS DENIEDonCreateFile; theImpersonatingfield shows whether SQL Server is acting as the service account or as the login that issuedALTER DATABASE.
Fix
Fix the cause the message names. Do not start with repair.
Path or drive wrong (error 2 or 3). The simplest fix is to put the volume or file back where physical_name says it should be, then bring the database online with ALTER DATABASE <database_name> SET ONLINE;, the statement Microsoft gives for retrying after the operating system problem is fixed. If the files really live somewhere else now, the catalog must be changed. Microsoft documents a "failure recovery procedure" for that. It involves stopping the instance and starting it with NET START MSSQLSERVER /f /T3608 (default instance), running ALTER DATABASE ... MODIFY FILE (NAME = logical_name, FILENAME = 'new_path\os_file_name'), stopping the instance again, moving the files, and starting normally. This stops the whole instance, so every database on it is unavailable while you do it. Plan the window, and follow the Microsoft page rather than this summary.
Permission denied (error 5). Make sure the Windows group Microsoft names (for a default instance, SQLServerMSSQLUser$ComputerName$MSSQLSERVER) has the permissions it needs on the file and that the group contains the service account. If the service account was changed outside SQL Server Configuration Manager, that is the supported tool for the change, so check that change first. Then retry with SET ONLINE.
File locked (error 32). Stop the other process from touching database files. The Microsoft antivirus guidance lists the data file extensions (.mdf, .ldf, .ndf), the backup extensions (.bak, .trn) and the SQL Server processes to exclude, and warns that "if any excluded file becomes infected, your antivirus software can't detect the infection", so a decision to exclude is a security decision. In a cluster, make sure the previous owning node has released the file handles.
Files missing. Restore from a valid backup. Microsoft's 17204 page adds two narrower options: if the missing file is in a secondary filegroup, the filegroup can be marked offline, the database brought online, and that filegroup restored alone; if the missing file is a transaction log, the FOR ATTACH and FOR ATTACH_REBUILD_LOG sections of the CREATE DATABASE documentation describe recreating it. Rebuilding a log can lose transactional consistency, so copy every remaining file first and read that documentation before acting.
Last resort only. If the database cannot be restored and cannot be started, Microsoft documents EMERGENCY mode and DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS. In Microsoft's words this is "an emergency last resort option recommended for use only if restoring from a backup isn't possible", and it "can result in more data loss than if you restore from a last known good backup". Before it, "you must create physical copies of the files that belong to this database", and Microsoft suggests setting the database to EMERGENCY first and extracting what you can from critical tables. EMERGENCY mode marks the database read-only with logging disabled and limits access to sysadmin (ALTER DATABASE SET options, DBCC CHECKDB). If the log is rebuilt there is "no full ACID guarantee", and the constraints need checking afterwards. This is a data-loss procedure for a specialist to decide on, not a routine step.
Confirm the fix
state_descisONLINEinsys.databases, and every file row insys.master_filesisONLINE.- The error log shows the database recovered without a new 17204, 17207 or 5120.
- Applications connect and the data they expect is there. For a database that was fixed by moving files, confirm
physical_nameis the path you intended. - If the cause was a missing file or any repair, run a full
DBCC CHECKDBand take a fresh full backup. Then restore that backup to another server and open it. A database that is online has not yet proved that its backups work.
What to watch afterwards
- Alert on 17204 and 17207 in the SQL Server error log or the Windows Application log. Microsoft lists both as the events produced when a database cannot be opened.
- Alert when any database has a
state_descother thanONLINE, with exceptions for databases deliberately offline. - Revisit the cause that applied. Drive letter changes, restores that put files in a new folder, and a service account change are all events to follow with a check of file permissions and a test start of the database.
- Keep antivirus exclusions documented and rechecked after each antivirus change.
Read next
Related articles you may want next.
- Backup & RecoverySQL Server Reports Corruption: Preserve Evidence FirstInterpret SQL consistency findings, preserve recovery options and plan a verified restore without turning data-loss repair into routine maintenance.Read article
- Backup & RecoverySQL User Databases Survived but the Instance Is Gone: Plan System-Database RecoveryBuild a version-aware recovery inventory for master, msdb, model and separately held instance dependencies.Read article
- TroubleshootingWindows Disk Full, VMware Space Free: Map the LayersMap Windows volumes to virtual disks and datastores, then identify where capacity is missing before approving an expansion or filesystem cleanup.Read article
Risks and limits
- These commands and procedures follow Microsoft documentation. They have not been run or lab-tested.
- The pages cited are Microsoft Learn documentation for SQL Server 2017 to 2025 on Windows. Linux and Azure SQL behaviour is not covered.
- Microsoft does not list every resource condition that can produce Recovery Pending. Where the error log names something other than a file open failure, follow that message.
- The Microsoft pages attach the wording "The system cannot find the file specified" to operating system error 3 in one place and error 2 in an example. Treat the number and text in your own log as authoritative.
- Several of the fixes interrupt service. Moving files by the failure recovery procedure stops the instance.
- Repair and log rebuild can lose data. Preserve copies of all files before trying them.
Sources
- Database States — Microsoft Learn, 20 October 2025, accessed 16 November 2026
- MSSQLSERVER_17204 — Microsoft Learn, 25 July 2020, accessed 16 November 2026
- MSSQLSERVER_17207 — Microsoft Learn, 25 July 2020, accessed 16 November 2026
- MSSQLSERVER_5120 — Microsoft Learn, 25 July 2020, accessed 16 November 2026
- sys.master_files — Microsoft Learn, 25 November 2023, accessed 16 November 2026
- File States — Microsoft Learn, 14 March 2017, accessed 16 November 2026
- Move user databases — Microsoft Learn, 19 September 2024, accessed 16 November 2026
- View the SQL Server Error Log (SSMS) — Microsoft Learn, 21 August 2025, accessed 16 November 2026
- ALTER DATABASE SET options — Microsoft Learn, 29 June 2026, accessed 16 November 2026
- DBCC CHECKDB — Microsoft Learn, 10 July 2026, accessed 16 November 2026
- Configure antivirus software to work with SQL Server — Microsoft Learn, 20 May 2026, accessed 16 November 2026
This article was originally published on .