Database Recovery
In this post I am going to describe a very simple issue I had today in regards to a database I was unable to access.
Firstly I ran a simple select to find out the state of the database:
SELECT state_desc FROM sys.databases WHERE name='DBName';
In this case the state_desc was RECOVERY_PENDING. With this in mind I tried to bring the database online:
ALTER DATABASE DBName SET ONLINE;
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “F:\SQL\Data\DBName.mdf”. Operating system error 2: “2(error not found)”.
Msg 945, Level 14, State 2, Line 1
Database ‘DBName’ 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.
The first line in the errors here was the major clue. Looking in the directory for the mdf file I could see it wasn’t present. Somehow these files had been removed and the database left in a RECOVERY_PENDING state.
I knew this instance was an old development instance that was not being used anymore, so in this case I just deleted the database.
More in depth information about this should the database have its files but for some reason be inaccessible can be found here
No trackbacks yet.