RECOVERY_PENDING appears when a resource error stops recovery and the database files are missing or unreachable. SSMS shows the state and T-SQL commands clear it without extra software. Five methods remove the state through the OS error, the file path, a log rebuild, a backup restore and recovery software. Free methods need the MDF file in good shape and a log rebuild needs a new full backup. Recovery software exports table records to CSV files so preview the tables before you export.
Recovery pending databases look broken because every query fails. Microsoft says the database is not damaged and the files are missing or blocked.
I created this guide because the old advice to delete the MDF and LDF files destroys good data. Stay tuned for the safe order of fixes and the one command that matters most.
What Does Recovery Pending Mean in SQL Server?
SQL Server reaches the RECOVERY_PENDING state when a resource error stops recovery during startup. Microsoft describes the database as not damaged and says the files are missing or system limits prevent the start.
Your database remains unavailable until you resolve the error and let recovery finish. Microsoft lists every state in its Database States Guide.
Error 17204 sends a user database to RECOVERY_PENDING. Error 17204 on a system database stops the SQL Server instance from starting.
Why Does SQL Server Set This State?
Five causes explain most recovery pending databases.
- Wrong Permissions. OS error 5 means Windows denies the SQL Server service access to the database file.
- Moved or Missing Files. OS error 3 means the file path stored in SQL Server points to a file that does not exist.
- File in Use. OS error 32 means another process, for example antivirus software, uses the file.
- Storage Not Ready. Network and iSCSI locations must be available before SQL Server starts.
- Low Resources. Error 945 appears when files are unreachable or memory and disk space are short.
Which Errors Put a Database in Recovery Pending?
Two startup errors name the failed file in the error log.
| Error | Message Meaning | User Database | System Database |
|---|---|---|---|
| 17204 | SQL Server could not open a database file | RECOVERY_PENDING | Instance does not start |
| 17207 | Windows returned an error while SQL Server opened a file | RECOVERY_PENDING | Instance does not start |
Microsoft explains in its Error 17204 Guide that SQL Server opens files with the Windows CreateFile function. OS error numbers in the message name the root cause.
How to Find the Affected Database in SSMS?
Open New Query, paste the query below and execute it. Rows in the result are your recovery pending databases.
SELECT d.name, d.state_desc, d.user_access_desc
FROM sys.databases AS d
WHERE d.state_desc = 'RECOVERY_PENDING';
List the file names and paths of the database next. Method two needs the logical name from this query.
SELECT name, physical_name, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'SalesDB');
Open SQL Server Logs under Management and select the current log. Search for 17204 or 17207 to find the OS error number.
Execute net helpmsg followed by the error number in Command Prompt when the log shows a number without text. For example net helpmsg 5 prints Access is denied.
What to Check Before the Fix?
Protect the data files before you alter anything.
- Files. Shut down the instance and duplicate every surviving database file on a separate disk.
- Account. Find the service account in SQL Server Configuration Manager.
- Paths. Compare the paths from sys.master_files with the real files in File Explorer.
- Backups. Locate the latest full backup plus all log backups after it.
- Space. Check that the disk for the database files has free capacity.
Which Free Methods Fix a Recovery Pending Database?
Four free methods remove the state. Start with method one because most cases end there.
Fix the OS Error and Set the Database Online (Free)
Microsoft lists the same fix for every OS error code. Resolve the error and bring the database online.
- Find the OS error number in the 17204 or 17207 message.
- For error 5, grant the service account of the instance access to the file. Microsoft names the group SQLServerMSSQLUser$ComputerName$MSSQLSERVER for a default instance.
- For error 3, correct the path or restore the missing file.
- For error 32, find the process that uses the file and stop it. Add the SQL Server database files to the exclusions of your antivirus software.
- Execute the command below.
ALTER DATABASE [SalesDB] SET ONLINE;
Edit the service account only in SQL Server Configuration Manager.
Point the Database to the Right Files (Free)
Use this method when the files exist in a new folder and SQL Server still looks at the old path.
- Get the logical file name with the second query from the earlier section.
- Execute the commands below for every moved file.
ALTER DATABASE [SalesDB]
MODIFY FILE (NAME = SalesDB_Data, FILENAME = N'E:\SQLData\SalesDB.mdf');
ALTER DATABASE [SalesDB] SET OFFLINE;
- Move the physical file to the new folder in File Explorer.
- Execute the SET ONLINE command from method one and query sys.master_files to confirm the new path.
Microsoft documents this sequence for a planned file move. Grant the service account rights on the new folder.
Rebuild a Missing Log File (Free, Breaks the Log Backup Chain)
Use this method when only the LDF file is gone. SQL Server rebuilds the log with a new 1 MB file in the default log location.
- Stop the SQL Server service and duplicate the MDF and NDF files into a folder like D:\Rescue.
- Start the service again.
- Execute the command below to attach the copies under a new name.
CREATE DATABASE [SalesDB_Copy]
ON (FILENAME = N'D:\Rescue\SalesDB.mdf')
FOR ATTACH_REBUILD_LOG;
- Take a full backup of the new database right away.
ATTACH_REBUILD_LOG works only for READ_WRITE databases that shut down cleanly. Microsoft states that the rebuild breaks the log backup chain.
Restore From a Backup (Free, Safest)
Microsoft says missing files need a restore from a valid backup. Restore the full backup first and apply the log backups in order.
RESTORE DATABASE [SalesDB]
FROM DISK = N'D:\SQLBackups\SalesDB_full.bak'
WITH REPLACE, NORECOVERY;
RESTORE LOG [SalesDB]
FROM DISK = N'D:\SQLBackups\SalesDB_log.trn'
WITH RECOVERY;
Restored data ends at the last log backup you apply. Open the BAK Restore Steps guide for the SSMS wizard.
Do not execute REPAIR_ALLOW_DATA_LOSS on a database that only lacks files. Repair deallocates rows and pages from a database that Microsoft calls undamaged. Our Suspect Database Fix guide explains the repair for truly damaged databases.
How to Fix Recovery Pending State With EmailDoctor Software?
Try EmailDoctor SQL Database Recovery if the MDF file is damaged and no backup exists. After the scan you see rules, triggers, functions, stored procedures, views and tables in the preview.
Demo versions preview all recovered objects for free and cap exports at 25 table records with 5 other objects.
Windows 7, 8, 10 and 11 work with .NET Framework 4.5 or higher. Free disk space of 100 MB is required and 4 GB RAM is recommended.
CSV export saves table records only. Stored procedures and triggers need the SQL Server database or script route.
Open and Scan the Database File
- Launch the recovery software after the installation.
- Click Open and select the MDF file copy.
- Choose Quick Scan and enable Auto detect to identify the SQL Server version. Select the version in the dropdown when detection fails.
- Open the NDF Options tab to attach secondary files. Choose automatic detection or click Add Files or Add Folder to attach NDF files yourself.
- When the scan report appears confirm the Quick Scan note.
Preview the Tables
- Select a table in the left panel and compare its records in the preview with what you expect.
Export the Tables to CSV Files
- Click Export and choose Export As CSV.
- Tick the tables you need in the list.
- Choose With Schema & Data to save the table structure and the records.
- Click Save and browse to the folder for the CSV files.
- Click OK in the Export Completed dialog and then Close.
- Open the folder to check the exported CSV files.
Select Advanced Scan if the Quick Scan preview shows fewer tables than the database should have. See the MDF File Repair Methods guide for the differences between both scan modes.
Which Method Fits Your Situation?
Match your OS error and file status to the method.
| Situation | Method | Data Loss | Price |
|---|---|---|---|
| Error 5, 32 or 945 | Fix the OS error | None | Free |
| Error 3 with files in a new folder | Point to the right files | None | Free |
| LDF file missing | Rebuild the log | Log backup chain breaks | Free |
| MDF or NDF file missing | Restore a backup | Data after the last backup | Free |
| MDF file damaged without backup | Software scan | Demo exports a record sample | Free demo then paid |
Which Snags Slow Down the Fix?
Check this list when a method fails.
- Same OS Error Returns. Check the permission of the service account again because SET ONLINE repeats the failed file open.
- Service Account Edited by Hand. Edit the account only in SQL Server Configuration Manager.
- File Still in Use. Confirm in a cluster that the previous node released the file handles.
- Attach Rejects the Files. Restore a backup instead because the files came from an unclean shutdown.
- Restore Refuses to Overwrite. Add the WITH REPLACE option to the RESTORE DATABASE command.
- State Returns After a Restart. Make the network or iSCSI storage available before SQL Server starts.
Frequently Asked Questions
Does Recovery Pending Mean Database Damage?
No. Microsoft states that the database is not damaged and that missing files or system limits stop the start.
Is Recovery Pending the Same as Suspect?
No. SUSPECT means SQL Server cannot recover the primary filegroup. RECOVERY_PENDING means a resource error stopped the recovery.
Does SET ONLINE Clear the State?
Yes when you fix the OS error first. Microsoft lists SET ONLINE as the step after the error is resolved.
Should I Delete the Database and Create It Again?
No. DROP DATABASE deletes the disk files of the database and you lose the data.
Does Error 17204 Stop the Instance?
Yes for a system database. User databases only move to RECOVERY_PENDING.
Can ATTACH_REBUILD_LOG Fix Any Database?
No. ATTACH_REBUILD_LOG needs a READ_WRITE database that shut down cleanly and it breaks the log backup chain.
Should I Take a Backup After a Log Rebuild?
Yes. Microsoft recommends a full backup right after the rebuild.
Can I Use REPAIR_ALLOW_DATA_LOSS Here?
No. Repair deletes rows and pages while this database needs its files back.
Can Recovery Software Open the MDF File Directly?
Yes. Recovery software opens the MDF file without bringing the database online and you preview the tables before any export.
Is the Demo Export Limited?
Yes. Free demo exports save a sample of 25 records per table with 5 other objects.
Final Words
Recovery pending means SQL Server could not reach a database file or a resource at startup. Every OS error in the log names the file and the cause.
Fix the permission or the path first and bring the database online. Never delete the MDF and LDF files of a database that only lacks access.
EmailDoctor software scans damaged MDF files and exports the tables to CSV files.
- Recovery pending databases are undamaged and lack access to files.
- OS error numbers decide the fix and SET ONLINE finishes it.
- Log rebuilds need a full backup afterward.
- Recovery software exports tables to CSV files when no backup exists.
Next Read: Fix a Suspect Database
Also Read: Repair a Corrupt MDF File | Open an MDF File