"Database [database name] cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details. (Microsoft SQL Server, Error: 945)"
Workable Solutions | Step-by-step Troubleshooting |
---|---|
Fix 1. Enlarge Hard Drive Space | As you can see in the error notification, the SQL database may not be opened due to...Full steps |
Fix 2. Make Sure Autogrowth Is On | Open SQL Server Management Studio and connect to the problematic database...Full steps |
Fix 3. Check the Account Permission | You need to check the account you are using and make sure you have...Full steps |
Fix 4. Check the MDF/NDF File | Find and right-click the ".mdf "or ".ndf" file of your database. Choose "Properties"...Full steps |
Fix 5. Use SQL Database Repair Tool | Stop MS SQL Server service. Press "Windows + R" and enter services.msc...Full steps |
Fix 6. Try DBCC CHECKDB | If there is no backup available, you can also try the DBCC CHECKDB repair option...Full steps |
SQL Server error 945 happens when a database is marked as "IsShutdown" or when the attaching and detaching of MDF file is not properly done and the recovery procedure fails to bring the database to a consistent state.
It may occur due to different reasons:
When you are bothered by the SQL Server error 945, there are six solutions to try.
According to user experience, there are effectiveness-based solutions to error 945 in SQL Server - Database cannot be opened due to inaccessible files. At the very beginning, you can restart your SQL database through ALTER DATABASE query. This query will help you to set the SQL Server database to online. If this doesn't work, figure out with the following methods.
As you can see in the error notification, the SQL database may not be opened due to insufficient disk space, getting rid of the unnecessary files on the corresponding hard drive or add a larger hard drive is a potential solution to the SQL Server error 945. If you are worried about data loss, you can back up the hard drive with free backup software in advance before the removal.
Since the database must be set to Autogrowth, you need to check and make sure the option is enabled. Here is the way to enable Autogrowth:
Step 1. Open SQL Server Management Studio and connect to the problematic database.
Step 2. Click "View" > "Object Explorer".
Step 3. Expand the "Database" folder.
Step 4. Right-click the database and choose "Properties".
Step 5. Under "Select a Page", choose "Files" and look for the Autogrowth settings and check the option "Enable Autogrowth".
You need to check the account you are using and make sure you have the correct permission to perform operations.
If the MDF or NDF file of the database is marked as read-only, you may encounter the SQL error 945. Thus, be sure that the MDF and NDF files are not shown as read-only. To remove read-only on the MDF or NDF file:
Step 1. Find and right-click the ".mdf "or ".ndf" file of your database. Choose "Properties" > "Security", then you will see Group or Username.
Step 2. Select the user you want to give access to the file and check the permission.
Step 3. If the permission is not set to Full Control, you need to change it by clicking "Edit".
Step 4. Then you will see the Group or Username box. In that box, select the user and choose "Full Control".
Go to the error log and see why the database goes wrong. If it is due to a persistent I/O error related to Application Programming Interface, a torn page, or other hardware issues then resolved it by restoring the database from backup. If you don't have any backup available, you can repair your SQL database with the professional MS SQL repair tool - Qiling MS SQL Recovery.
Let's see how to repair your database with it:
Step 1. Stop MS SQL Server service
Press "Windows + R" and enter services.msc.
Find and double-click "SQL Server (instant name)".
In the Properties windows, click "Stop" to end the SQL Server and click "Apply" to confirm.
Step 2. Run Qiling SQL repair tool, select file types and click "Next" to start.
Step 3. Choose the corrupted MDF/NDF file. Then click "Scan" to start analyzing your MDF/NDF file.
If you know the exact location of the file, click "Browse" to locate the database.
If you don't know the file location, click "Search" to search for the .mdf or .ndf file in.
Step 4. When it has done, you will see all the database objects listed in the left pane of the window. Choose the database objects you'd like to repair and click "Recover".
Step 5. Choose a preferred way to export the database data: "Export to database" or "Export as SQL scripts". If you select "Export to database", you need to further select the server information, log into your account, and select a destination database, either a new one or an existing one.
Step 6. Before you click "OK", now you need to restart the SQL Server.
Press "Windows + R" and enter services.msc.
Find and double-click "SQL Server (instant name)".
In the Properties windows, click "Start" to restart the SQL Server service and click "Apply" to confirm.
Step 7. Click "OK" to save the repaired files to your desired SQL database.
If there is no backup available, you can also try the DBCC CHECKDB repair option. However, it is not recommended since it may induce the Suspect Mode of your SQL database, which may further lead to another SQL Server database error 926. (Click to see more SQL database errors.)
We focused on one of the most common SQL server issues, error 945. We have discussed the possible reasons and solutions to fixing database that cannot be opened due to inaccessible files or insufficient memory or disk space issue. You can try the manual methods to fix SQL server error 945 like enlarge hard drive space, checking account permission, checking database files, and trying DBCC CHECKDB.
For an easier approach, Qiling SQL repair tool is worth trying. It offers the simplest way to repair corrupted (.mdf and.ndf) files, fix database log files, and recover damaged objects.
Similar to SQL error 945, SQL error 926 can also occur due to improper connection to SQL Server or using the RESTORE database or RESTORE LOG procedures, showing the error message "Database cannot be opened. It has been marked SUSPECT by recovery". Take the following ways to solve this problem.