Wednesday, October 15, 2014

Database in Recovery Pending State



Database 'db_name' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.
Looks like Log file got corrupted and not allowing the database to come online. 


First thing make sure you have .mdf and .ldf files in your drives. 
next verify 

select * from sys.sysdatabases where name ='db_name'

Verify the filename column sees the database .mdf file with full path. 

Next 

Execute the following commands to bring your database to online. 

alter database [db_databasename] set offline with rollback immediate
alter database [db_databasename] set online with rollback immediate
with this your database is online and accessible. 

I would also recommend to run the following command to make sure no corruption. 

DBCC CHECKDB ('db_databasename')