[Fixed] SQL Error 945 | Database Cannot Be Opened due to Inaccessible Files - Qiling  

[Fixed] SQL Error 945 | Database Cannot Be Opened due to Inaccessible Files


The error message "Database [database name] cannot be opened due to inaccessible files or insufficient memory or disk space" indicates that the SQL Server is unable to access the database files or that the system does not have enough memory or disk space to open the database. To resolve this issue, you can refer to the SQL Server error log for more details and take necessary actions such as checking disk space, memory, and database file accessibility.

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

What Is SQL Error 945

SQL Server error 945 occurs when a database is marked as "IsShutdown" or when the attaching and detaching of MDF files is not properly done, causing the recovery procedure to fail and the database to remain in an inconsistent state.

SQL error 945

It may occur due to different reasons:

When encountering the SQL Server error 945, there are six potential solutions to try and resolve the issue. These solutions can help you troubleshoot and fix the problem, allowing you to continue with your database operations without interruption.

How to Fix SQL Error 945 Database Cannot Be Opened Due to Inaccessible Files or Insufficient Memory or Disk Space in 6 Ways

According to user experience, effectiveness-based solutions exist for error 945 in SQL Server, which prevents the database from being opened due to inaccessible files. A simple solution is to restart your SQL database through an ALTER DATABASE query, which can set the SQL Server database to online. If this doesn't work, other methods can be tried.

Fix 1. Enlarge Hard Drive Space

The SQL Server error 945 may occur due to insufficient disk space, which can be resolved by removing unnecessary files or adding a larger hard drive. If data loss is a concern, backing up the hard drive with free backup software before removal is recommended.

Fix 2. Make Sure Autogrowth Is On

To enable Autogrowth in a database, you can follow these steps:

Step 1. To resolve the issue with SQL Server Management Studio not being able to connect to a database, first open SQL Server Management Studio and connect to the problematic database. Then, check the SQL Server service is running and the SQL Server Browser service is also running.

Step 2. Click "View" > "Object Explorer".

Step 3. Expand the "Database" folder.

Step 4. Right-click the database and choose "Properties".

Step 5. To enable Autogrowth, go to the "Select a Page" section, choose "Files", and look for the Autogrowth settings. Select the option to "Enable Autogrowth".

Fix 3. Check the Account Permission

You need to check the account you are using and make sure you have the correct permission to perform operations.

Fix 4. Check the MDF/NDF File of the Database

If the MDF or NDF file of the database is marked as read-only, you may encounter the SQL error 945. To resolve this, ensure the MDF and NDF files are not shown as read-only. To remove read-only on the MDF or NDF file, right-click on the file and select "Properties", then uncheck the "Read-only" box and click "Apply" and "OK" to save the changes. This should resolve the SQL error 945.

Step 1. To access the file properties of your database's ".mdf" or ".ndf" file, right-click on it, select "Properties", and then go to the "Security" tab, where you can see the group or username associated with the file.

Step 2. To give access to a file, select the user you want to give access to the file and check the permission that you want to grant them, such as read or write.

Step 3. If the permission is not set to Full Control, you need to change it by clicking "Edit".

Step 4. In the Group or Username box, select the user and choose "Full Control".

Fix 5. Use SQL Database Repair Tool

Go to the error log to identify why the database is malfunctioning. If it's due to a persistent I/O error, torn page, or hardware issues, resolve it by restoring the database from a backup. If no backup is available, use a professional MS SQL repair tool like Qiling MS SQL Recovery to repair the SQL database.

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)".

To end the SQL Server, click "Stop" in the Properties window, and then confirm with "Apply".

Step 2. Run the Qiling SQL repair tool, select the desired file types, and click "Next" to initiate the repair process.

Select file types that you want to recover

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 the "Browse" button to locate the database.

If you're unsure where the database file is located, click on the "Search" button to search for the .mdf or .ndf file in your system. This will help you find the file's location.

select the location to scan for the SQL database file

Step 4. When the process is complete, all database objects will be listed in the left pane of the window. Select the desired database objects and click "Recover" to initiate the repair process.

recover the database objects

Step 5. To export database data, you can choose between two options: "Export to database" or "Export as SQL scripts". If you select "Export to database", you'll need to specify server information, log into your account, and choose a destination database, either creating a new one or using 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 window, click "Start" to restart the SQL Server service and confirm with "Apply".

Step 7. To save the repaired files to your desired SQL database, click "OK" on the prompt.

Fix 6. Try DBCC CHECKDB Repair Option

If there is no backup available, you can try the DBCC CHECKDB repair option, but it's not recommended as it may put your SQL database in Suspect Mode, potentially leading to another SQL Server database error 926.

Wrap Things Up

We addressed the common SQL server issue, error 945, which prevents database opening due to inaccessible files, memory, or disk space issues. Possible solutions include manual methods such as increasing hard drive space, checking account permissions, verifying database files, and running DBCC CHECKDB.

For a simpler approach to repairing corrupted SQL database files, the Qiling SQL repair tool is worth considering. It offers a straightforward way to fix damaged .mdf and .ndf files, resolve issues with database log files, and recover objects that have been compromised.

More Info: How to Fix SQL Server Error 926

SQL error 926 can occur due to an improper connection to SQL Server or when using the RESTORE database or RESTORE LOG procedures, resulting in the error message "Database cannot be opened. It has been marked SUSPECT by recovery". To resolve this issue, take the necessary steps to correct the connection or troubleshoot the RESTORE procedures.

Related Articles


Is this information helpful?     

What can we do to improve this information? (Optional)
Refresh Please enter the verification code!


QilingTech uses cookies to ensure you get the best experience on our website.  Learn more  Got it