SQL Server Error 930 occurs when the database engine cannot access a required recovery unit, typically because a file is missing, corrupted, or locked by another process. To resolve this, you must identify the specific file causing the error via the SQL Server Error Log and then either restore the missing file from a backup, fix the underlying disk permissions, or use the EMERGENCY mode and DBCC CHECKDB command to repair the database. This error prevents the database from transitioning to an ONLINE state, leaving it in RECOVERY or SUSPECT mode.
What You'll Need
- Administrative access to the SQL Server instance (sysadmin role).
- Access to the SQL Server Error Log.
- SQL Server Management Studio (SSMS) or sqlcmd.
- A valid full backup of the database (if performing a restore).
- Operating system-level administrative privileges to check folder permissions and disk health.
Step-by-Step
- Identify the Faulty File: Open SQL Server Management Studio (SSMS). Navigate to Management > SQL Server Logs. Double-click the current log. Search for "Error 930". The log entry will specify which recovery unit (usually a .mdf or .ldf file) is causing the failure. Note the exact file path and filename mentioned in the error message.
- Verify Physical File Existence: Open Windows File Explorer and navigate to the path identified in the error log. Verify that the file actually exists on the disk. If the file is missing, you must locate it from a backup or a mirrored drive. If the file is present, proceed to check permissions.
- Check File Permissions: Right-click the database file (.mdf or .ldf) and select Properties > Security. Ensure that the service account running the SQL Server instance has "Full Control" over the file and the folder containing it. If the SQL Server service was recently migrated to a new service account, the previous permissions may no longer be valid, triggering Error 930.
- Check for External Locks: Ensure that no other application (such as an antivirus scanner, a third-party backup agent, or another instance of SQL Server) is locking the file. If a backup software is currently locking the file for a snapshot, the database engine may be unable to reference the recovery unit. Temporarily disable the security software or stop the backup agent to test if the database can come online.
- Attempt a Manual Database Attach: If the database is in a SUSPECT state and you have the files, try detaching the database (if possible) and re-attaching it. Right-click the Databases folder > Attach. Add the .mdf file and ensure the .ldf file path is correct. If the log file is missing or corrupted, you may attempt to attach without it, though this is risky and can lead to data loss.
- Use EMERGENCY Mode for Repair: If the files exist but the recovery unit is corrupted, you must force the database into a state where it can be repaired. Execute the following T-SQL commands:
ALTER DATABASE [YourDatabaseName] SET EMERGENCY;ALTER DATABASE [YourDatabaseName] SET SINGLE_USER;
This allows the administrator to access the database even if it is corrupted. - Run DBCC CHECKDB: Once in EMERGENCY mode, run the repair command. Be aware that REPAIR_ALLOW_DATA_LOSS is the only option that can fix many Error 930 scenarios, but it may delete corrupted pages to make the database structurally sound.
DBCC CHECKDB ([YourDatabaseName], REPAIR_ALLOW_DATA_LOSS);
After the process completes, set the database back to multi-user mode:ALTER DATABASE [YourDatabaseName] SET MULTI_USER; - Restore from Backup: If DBCC CHECKDB fails or if you cannot afford data loss, the safest path is to restore the database from the last known good backup. Right-click Databases > Restore Database. Select the source device and ensure you overwrite the existing corrupted files.
Common Mistakes
One of the most frequent mistakes is attempting to delete the .ldf (log) file manually from Windows Explorer to "force" SQL Server to create a new one. This often exacerbates Error 930 because the recovery unit reference in the system metadata still expects the original log file, leading to a mismatch that prevents the database from starting. Never delete database files manually unless you are performing a specific recovery procedure guided by official documentation.
Another common error is running DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS without first taking a file-level backup of the corrupted state. If the repair process makes the data worse or deletes critical tables, you will have no way to return to the previous state to try a different recovery method. Always copy the .mdf and .ldf files to a secure location before attempting destructive repairs.
Users also frequently overlook the SQL Server service account. They may grant permissions to their own Windows user account but forget to grant them to the specific account (e.g., NT Service"). This results in the file being visible to the admin but inaccessible to the SQL engine, triggering the recovery unit error.
Tips
To prevent Error 930 in the future, implement a strict disk monitoring strategy. Many recovery unit errors are the result of "bit rot" or failing sectors on a physical hard drive. Using RAID configurations or mirrored storage can provide redundancy that prevents a single disk failure from taking down a recovery unit.
Regularly perform "Restore Tests." Having a backup is only half the battle; knowing that the backup is valid and can be restored quickly reduces the downtime associated with Error 930. Use a separate test server to periodically restore your production backups.
Keep your SQL Server instance updated. Some recovery unit errors are caused by bugs in the storage engine that are resolved in later Cumulative Updates (CUs). Check the official update catalog for your specific version of SQL Server.
Troubleshooting
If the database remains in a SUSPECT state after following the steps above, check the Windows Event Viewer (System and Application logs). Look for "Disk" or "ntfs" errors. If you see "The device has a bad block," the issue is hardware-related, and no amount of T-SQL commands will fix the file. You must move the files to a healthy disk and then attach them.
If you encounter an "Access Denied" error while trying to set the database to EMERGENCY mode, ensure that no other users are connected to the instance. Use sp_who2 to identify active sessions and kill them using the KILL [SPID] command before attempting to change the database state.
If the log file is permanently lost and you cannot restore it, you can try to rebuild the log using the FOR ATTACH_REBUILD_LOG clause. This should only be done as a last resort, as it assumes the database was shut down cleanly. If the database was in the middle of a transaction, this can lead to logical inconsistency.
Frequently Asked Questions
Can Error 930 happen on a healthy hard drive?
Yes. It can be caused by incorrect file permissions, antivirus software locking the file, or corruption within the SQL Server internal metadata rather than a physical disk failure.
Will REPAIR_ALLOW_DATA_LOSS delete my entire database?
No, it will not delete the whole database, but it will delete specific data pages that are too corrupted to be fixed. This means some rows in some tables may be lost, but the rest of the database will become accessible again.
Is Error 930 the same as a corrupted index?
No. Index corruption usually allows the database to stay online but causes errors during specific queries. Error 930 is a critical failure that prevents the database from starting because a fundamental recovery unit is unreachable.
How do I know if my SQL Server service account has the right permissions?
Check the Services console (services.msc), find the SQL Server instance, and look at the "Log On As" column. Then, ensure that specific account is listed in the Security tab of the folder where your .mdf and .ldf files are stored.
Can I fix Error 930 without a backup?
It is possible using EMERGENCY mode and DBCC CHECKDB, but there is a high risk of data loss. If the physical file is missing and you have no backup, the data is generally unrecoverable.