In case database is showing in 'Recovery Pending state, it means that recovery cannot be started. Until the cause is get fixed, recovery cannot run and the database cannot come online. You can check the state of the database by using sys.databases catalog view. Here are many reasons of this SQL Server behavior, the most common one is the log file is missing or corrupt. The other ones are:
- MDF file get corrupted.
- No enough space available for the SQL Server to recover the database during startup.
- Database cannot be opened due to inaccessible files or insufficient memory or disk space.
- Database files are being held by operating system.
- Sudden SQL Server Shutdown, Power failure or a Hardware failure.
First you should check following two points:
1.First you should check that MDF & LDF file is exist or not?
2.Is Drive is available?
If so then you should drop the DB and restore from backup. If you don't have backup then use following steps to resolve the issue:
- you should try stopping SQL Service
- Free up some space, make sure there's enough space there for the recovery to complete
- Now Restart the SQL service to get back SQL database online again.
After using all following steps if you are unable to resolve this error, it means that the error occurs due to log file corruption. In this case, you have last resort that is Switch the database to emergency mode, then to single user mode, run DBCC CHECKDB with the repair_allow_data_loss option. This command will lose data & have chances that may not work. If it doesn't work, there are no further alternatives, so try this command when no other options are available.
Hope the article will help you to get back your database in online state!!