SQL SERVER – FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details
This error is very common and many times, I have seen affect of this error as Suspected Database, Database Operation Ceased, Database Stopped transactions. Solution to this error is simple but very important.
Fix/Solution/WorkAround:
1) If possible add more hard drive space either by removing of unnecessary files from hard drive or add new hard drive with larger size.
2) Check if the database is set to Autogrow on.
3) Check if the account which is trying to access the database has enough permission to perform operation.
4) Make sure that .mdf and .ldf file are not marked as read only on operating system file system level.
Reference : Pinal Dave (http://blog.SQLAuthority.com)












Pinal, thanks for your posts!
Yes it is the common issue for DBA, here’s my troubleshooting steps:
STEP1: identify the db status:
use master
select databaseproperty(‘db_name’,'isShutdown’)
Most of them it would return 1 in this situation
STEP2: Clear up the internal db status:
use master
alter database db_name set offline
it would return with no error in most cases
STEP3: Get detail error message:
use master
alter database db_name set online
After step3, sql server will first verify the log file, if the log file is okay, it will verify the rest of the data file(s). Most of time it is because of the file location or file properties setting. For example if it is file location issue:
alter database db_name
modify (file=’logical name’, filename=’physical name’)
go
This one really solved my problem. Thank you very much!
Hi Z2,
Thank you very much for your help. This really solved my problem which i was facing since last 12 hrs.
Hiten
Thank you!!
This one was the solution for my problem. Thank you.
excellent Z2… thanks for the answer solved my problem in few seconds
Thanks! it fixed my problem. btw which user should have access to the physical files?
thanks this solved the problem for us.
Thank you so much,this solved my problem
Thanks for that post, when I set it back online there were no errors and the db was accessible again, ran checkdb with no error or issues. in the log it showed rolling transactions forward and one back. Also in the log I saw “informational” message regarding writting checkpoint to that db… pretty sure this problem started due to a diskspace shortage. Either way thanks for the response. And thank you Pinal, your blog posts have been very helpful to me in the past, keep up the good work!
Thanks a lot! Worked just fine!
It’s still a very useful
Thank You so much Z2.. Really worked..
Hey you have great instructions but what if someone goes through the steps that you identified then what? What are the possible Scenarios?
YOU ARE THE MAN!, THANKS :D
Thanx man you are a lifesaver for us new DBAs
Perfect set offline them online worked like a charm
many thankz
in step 3 am nt clear..
my code
alter database cvssss modify (file=’logical name’, filename=’physical name’)
i got error
Incorrect syntax near ‘(‘.
Try this syntax, it will work :)
alter database cvssss
modify file(name=’logical name’, filename=’physical name’)
go
Hello!!
I am getting follwoing error after executing Alter database db_name set online:
I/O error (bad page ID) detected during read at offset 0×00000000030000 in file ‘C:\Program Files\Microsoft SQL Server\MSSQL\Data\IT_Data.MDF’.
Connection Broken
what to do?
Urgent ):
Hola, si son usuarios genexus, este error puede ser producido debido a que borraron la KB manualmete, es decir, unicamente borraron el folder donde se aloja la KB
c:/…./models/nombre_KB
y seguramente intentaron generar una nueva kb, genexus da por default al nombre de la base de datos: GX_KB_NOMBRE_DE_LA_KB, así que si esta base de datos ya existia se producira dicho error,
para corregirlo basta con cambiar el nombre de la base de datos que genexus da por default.
Saludos
nice one… its really saved my time… coz most of my databases are corrupted
If you’re getting an incorrect syntax, make sure when you paste the query into SQL Query Analyzer you remove the apostrophe around db_name or filename, etc. and replace with a new apostrophe.
It may some times you just move your database files from the older location to new location… So just veryfy that..
Thanks Pinal and Z2, I did offline and online, my database is up now.
Hello,
After step 3 you have mentioned this query
alter database db_name
modify (file=’logical name’, filename=’physical name’)
go
whether if we get any error message then only we have to execute this query or is it compulsary to execute this query,
and that logical name means whether we can mention any name or the name which the error files is having.
because I am in confusion of this logical name and physical name.
Thanks
sharanu.
Dear Friends,
I am getting this error when i run the last step of the given patch, please kindly give me the solution my production server has stoped. and feeling too much pressure.
the error message is:
Msg 233, Level 20, State 0, Line 0
A transport-level error has occurred when sending the request to the server. (provider: Named Pipes Provider, error: 0 – No process is on the other end of the pipe.)
STEP1: identify the db status:
use master
select databaseproperty(’AdminBack’,’isShutdown’)
STEP2: Clear up the internal db status:
use master
alter database AdminBack set offline
STEP3: Get detail error message:
use master
alter database AdminBack set online
these three steps is not working in mirror server ….
am facing an error after configure Database mirroring
but the problem is mirror server
” cannot show requested dialog (sqlmgmt)
an exception occured while executing a transact-sql statement
or batch (microsoft.sqlserver.connectioninfo)
the database “testing” cannot be openned.it is acting as a mirror
database(microsoft sql server error:954) “
Hi,
I am not able to access my msdb.
Each time i try to access the database it gives the following error:
MSDB is not accessible. error 945.
Can anyone please help me..??????
Thanks !!!
That was perfect answer for the trouble…Thanks a lot for the solution
Msg 5041, Level 16, State 2, Line 1
MODIFY FILE failed. File ‘MSDBData.mdf’ does not exist.
I am getting this error in the 3rd step. how to get the msdbdata.mdf file. I can able see the msdb database in Management studio physically. but i cant able to access it. how to troubleshoot it. Pls help.
Hi Pinal,
I don’t know if you can help me here.
I can’t start my sql server services. I have tried to move the system databases to the specific drives from the default sql server path…
I have successfully moved the data and log files for master,msdb,model but i can’t start my services back and getting this error…
2009-08-26 04:45:41.89 spid9s Starting up database ‘model’.
2009-08-26 04:45:41.89 spid9s Error: 17207, Severity: 16, State: 1.
2009-08-26 04:45:41.89 spid9s FCB::Open: Operating system error 5(error not found) occurred while creating or opening file ‘S:\MSSQL\Data’. Diagnose and correct the operating system error, and retry the operation.
2009-08-26 04:45:41.89 spid9s Error: 17204, Severity: 16, State: 1.
2009-08-26 04:45:41.89 spid9s FCB::Open failed: Could not open file S:\MSSQL\Data for file number 1. OS error: 5(error not found).
2009-08-26 04:45:41.89 spid9s Error: 5120, Severity: 16, State: 101.
2009-08-26 04:45:41.89 spid9s Unable to open the physical file “S:\MSSQL\Data”. Operating system error 5: “5(error not found)”.
2009-08-26 04:45:41.90 spid9s Error: 17207, Severity: 16, State: 1.
2009-08-26 04:45:41.90 spid9s FCB::Open: Operating system error 5(error not found) occurred while creating or opening file ‘S:\MSSQL\logs’. Diagnose and correct the operating system error, and retry the operation.
2009-08-26 04:45:41.90 spid9s Error: 17204, Severity: 16, State: 1.
2009-08-26 04:45:41.90 spid9s FCB::Open failed: Could not open file S:\MSSQL\logs for file number 2. OS error: 5(error not found).
2009-08-26 04:45:41.90 spid9s Error: 5120, Severity: 16, State: 101.
2009-08-26 04:45:41.90 spid9s Unable to open the physical file “S:\MSSQL\logs”. Operating system error 5: “5(error not found)”.
2009-08-26 04:45:41.90 spid9s File activation failure. The physical file name “S:\MSSQL\logs” may be incorrect.
2009-08-26 04:45:41.90 spid9s Error: 945, Severity: 14, State: 2.
2009-08-26 04:45:41.90 spid9s Database ‘model’ cannot be opened due to inaccessible
Vielen Dank, die Hinwiese mit online/offline waren meine Rettung!
Gr8 Stuff!!
But ill need to know why it crashed like that…
Tisk! Tisk!
It work fine to me, thanks.
Off-line script and then on-line script worked like a charm.
Cheers Peenal.
Saved my day again.
Thanks so much!!
I had a database on a computer and somebody wiped out my user account.. and I couln’t get access to it… This saved me!!
set databases offline and then online worked.
Excellent ,after taking offline and bringing online it worked awesonly….thanks very much
Hallo
Unchecking the “compress contents to save disk space” on .mdf and .lds files also helps.
Thanks
Life saver :)
Off-line script and then on-line script worked like a charm.
Thanks a lot.
another easy solution could be, when you take the database online, it will tell you which files is it looking for.
i came across the same issue and came to know that the dbname
reportserver2TempDB was actually having files reportservertempdb.mdf and .ldf
but when it tries to load the database it looks the files with the nam reportserver2tempdb.mdf and.ldf
so what you can do is, stop the sql service and rename the files and now restart the service. and your db will be accesible :)
Thanks man!!! it works:)
i got error on step 1, so i skip step 1 and execute step 2 and 3, and it still works.
Thanks alot
I got following error while trying to run
alter database db_name set online
Msg 945, Level 14, State 2, Line 1
Database ‘db_name’ cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
Msg 1101, Level 17, State 12, Line 1
Could not allocate a new page for database ‘db_name’ because of insufficient disk space in filegroup ‘DEFAULT’. Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.
USE master;
GO
ALTER DATABASE TEKADIM SET EMERGENCY
GO
ALTER DATABASE TEKADIM SET SINGLE_USER
GO
DBCC CHECKDB (TEKADIM, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS;
GO
USE TEKADIM;
DBCC CHECKDB WITH NO_INFOMSGS;
GO
USE TEKADIM
ALTER DATABASE [TEKADIM] SET RECOVERY SIMPLE
GO
DBCC SHRINKFILE ([TEKADIM_log])
GO
ALTER DATABASE [TEKADIM] SET RECOVERY FULL
DBCC SHRINKFILE (TEKADIM, 1) WITH NO_INFOMSGS
ALTER DATABASE TEKADIM SET MULTI_USER
Ali,
What exactly does this script do? I am getting this error on some, but not all after failing over a SQL server using VMWare site recovery manager. Am I losing data here with this script? The “Repair_allow_data_loss” option sounds like we are losing data. Is there a way to compare against a good copy of the database to see if there really is any data loss?
Jake
Mind blowing solution….u really save my life…….my job ws on risk…thank u so much for the solution…..thanks a lot
Excellent…really good and thanks for the solution
Thank you very much! It solved the problem.
2010-09-10 12:02:56.10 Server Microsoft SQL Server 2005 – 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
2010-09-10 12:02:56.10 Server (c) 2005 Microsoft Corporation.
2010-09-10 12:02:56.10 Server All rights reserved.
2010-09-10 12:02:56.10 Server Server process ID is 2200.
2010-09-10 12:02:56.10 Server Logging SQL Server messages in file ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG’.
2010-09-10 12:02:56.10 Server This instance of SQL Server last reported using a process ID of 1380 at 10-Sep-10 11:09:08 AM (local) 10-Sep-10 5:39:08 AM (UTC). This is an informational message only; no user action is required.
2010-09-10 12:02:56.10 Server Registry startup parameters:
2010-09-10 12:02:56.10 Server -d C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf
2010-09-10 12:02:56.10 Server -e C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG
2010-09-10 12:02:56.10 Server -l C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf
2010-09-10 12:02:56.12 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2010-09-10 12:02:56.14 Server Detected 2 CPUs. This is an informational message; no user action is required.
2010-09-10 12:02:56.92 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2010-09-10 12:02:56.95 Server Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2010-09-10 12:02:56.98 Server The Microsoft Distributed Transaction Coordinator (MS DTC) service could not be contacted. If you would like distributed transaction functionality, please start this service.
2010-09-10 12:02:56.98 Server Database Mirroring Transport is disabled in the endpoint configuration.
2010-09-10 12:02:56.98 spid4s Starting up database ‘master’.
2010-09-10 12:02:56.98 spid4s Error: 17207, Severity: 16, State: 1.
2010-09-10 12:02:56.98 spid4s FCB::RemoveAlternateStreams: Operating system error (null) occurred while creating or opening file ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf’. Diagnose and correct the operating system error, and retry the operation.
2010-09-10 12:02:57.06 spid4s SQL Trace ID 1 was started by login “sa”.
2010-09-10 12:02:57.09 spid4s Starting up database ‘mssqlsystemresource’.
2010-09-10 12:02:57.15 spid4s Error: 15297, Severity: 16, State: 1.
2010-09-10 12:02:57.15 spid4s The certificate, asymmetric key, or private key data is invalid.
2010-09-10 12:02:57.15 spid4s SQL Trace was stopped due to server shutdown. Trace ID = ’1′. This is an informational message only; no user action is required.
I get this error when trying to put the db online:
An error occurred while processing the log for database ‘UtlititiesPlus’. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log. what can i do?
Thanks, I got the solution.
THIS DOES WORK AND IS THE ONLY SCRIPT THAT DOES
USE master;
GO
ALTER DATABASE TEKADIM SET EMERGENCY
GO
ALTER DATABASE TEKADIM SET SINGLE_USER
GO
DBCC CHECKDB (TEKADIM, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS;
GO
USE TEKADIM;
DBCC CHECKDB WITH NO_INFOMSGS;
GO
USE TEKADIM
ALTER DATABASE [TEKADIM] SET RECOVERY SIMPLE
GO
DBCC SHRINKFILE ([TEKADIM_log])
GO
ALTER DATABASE [TEKADIM] SET RECOVERY FULL
DBCC SHRINKFILE (TEKADIM, 1) WITH NO_INFOMSGS
ALTER DATABASE TEKADIM SET MULTI_USER
Thanks a lot its perfectly worked. Solve my problem of 1 week.
Thanks for the help. It saved my time.
V gud…
Thank you very it helped a lot.
Hi Pinal,
This very common error when disk space is low that database goes to inassessiable mode. Thanks for usefull article
Regards
Jayant Dass
Thank alot bro..
it helped a lot and useful
hey thanks a lot, this one solved my problem…
i am from Africa-Mozambique and you dont know how it helped me.
thanks
thanks..
Many many many thanks! I can’t begin to say how this has helped me!
Thank you Pinal for this post!
Following the provided solution help to resolve my issue.
I cleaned the drive off unwanted stuff and then apply this
use master
alter database db_name set online
Issue resolved.
Thanks a lot this saved me so many problems I had been looking at this issue for a day
Excellent
Thank you very much. Solved my db issue
Z2, thanks!!!!!
Hi its Moti
I have a strange problem
My Master Database is corrupt
When i m starting the sqlserver it didn’t start
Can anyone help me plz….
Thank you very much
How come I can rename an attached mdf file, thereby making the associated databases inaccessible, but when I try to copy said mdf file, it’s locked?
Right click on the folder C:\ArrowSQL\Arr@Data and click on properties
Click on security tab
Click on Add button and add sql service account
Provide modify privilege and click ok
Verify both mdf and ldf have modify privilege
Attach the db!
Worked for me too. additionally I had to play with permissions setting for mdf file. Thanks.
Am frequently getting below message from my DMS database, i googled a lot to get a workable solution, no success yet. Can anybody help to resolve this ?
Could not find database ID 2, name ‘tempdb’. The database may be offline. Wait a few minutes and try again.
Raghu korambath.
Thanks a lot dear… thats worked…
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “c:\myworks_master.mdf”. Operating system error 5: “5(Access is denied.)”.
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “c:\myworks_log.ldf”. Operating system error 5: “5(Access is denied.)”.
Msg 945, Level 14, State 2, Line 1
Database ‘myworks’ cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “c:\myworks_master.mdf”. Operating system error 5: “5(Access is denied.)”.
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “c:\myworks_log.ldf”. Operating system error 5: “5(Access is denied.)”.
Msg 945, Level 14, State 2, Line 1
Database ‘myworks’ cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
My database is read only , i made it offline and trying increasing file size it show the same error.
Does any one clear my issue..
Thanks in advance…!
Make sure you have specified the server’s file path and not local file path
This post saved my bacon, thanks gents!!
Thank you for the post, this saved the bacon!!
This my first stop when looking for answers. Great site and great commenters.
thanks a lot
TY TY, worked like a charm
Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details
Please help me as i cant log in
I have a DB with two data files in the filegroup — one large (2T) and one small (3G) added in case of spillover. SQL had not yet started to use the spillover file, but I lost the disk that housed it. The large file is still available, but I can’t get the DB online because one of the files in the filegroup is gone.
Any thoughts on how I can get this DB online again?
Failing that, any thoughts on how I could recover the data from the large file?