Labels

Friday, 25 August 2017

How to fix log cannot be rebuilt the database because the database was not cleanly shut down

Requirement : I got few mdf and ldf files from client and requested to restore the databases on production environment. I got the below error for one of the database during mdf and ldf attachment.

"File activation failure. The physical file name "G:\MS SQL Server 2005 Data Files\MSSQL.1\MSSQL\DATA\TEST.ldf" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down."

Resolution :

I have used the below command to fix the issue.
CREATE DATABASE TEST ON (FILENAME = 'R:\SQL Data\TEST.mdf')
FOR ATTACH_FORCE_REBUILD_LOG

Note : Make sure service account or your user has the proper access to place the files in respective drive.

No comments:

Post a Comment