Msg 9001, Level 21, State 1, Line 1 (The log for database ‘ ‘ is not available. Check the event log for related error messages. Resolve any errors and restart the database.)
While trying to take a backup or even to update statistic, you may experience error as below:
Msg 9001, Level 21, State 1, Line 1
The log for database ' Database_Name ' is not available. Check the event log for related error messages. Resolve any errors and restart the database.
Such errors are also reported in SQL Server log and indicates a corruption in log file of the database. You need to fix it with high priority before the corruption escalates.
Easiest way to fix this is to use one of the below option. However please be careful to use them as they may cause data loss in some case (specifically for Option 2 with rebuild log and Option 3)
Options:
- Take database offline and bring back online. Then execute a checkdb to find if there is any corruption.
- Simply detach the database and attach it back. Then execute a checkdb to find if there is any corruption. If still error persists, attach the database back with rebuild log option. (Please refer to http://blog.consultdba.com/2010/03/attaching-database-with-out-log-file.html to know how to attach a database with out a log file). This also must be followed by a checkdb to ensure error is resolved.
- Restore a last known good backup. Make sure to execute a checkdb.
This problem should be resolved using one of the above options. (Option 2 with rebuild log and Option 3 will surely resolve this issue as long as it is from a logical corruption). However if you still face the issue, please consider the possibility of having problem with hardware also.
Example failure from this error while attempting to take a full backup of “testdb”:
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Msg 9001, Level 21, State 1, Line 1
The log for database ' testdb” is not available. Check the event log for related error messages. Resolve any errors and restart the database.
Comments
Thanks for you post, it helped me when I got the same errors you've mentioned.
Cheers
Roni.