2

I have a .mdf file which contains more than 30 GB data. On trying to attach this to SQL on one of our standalone dev servers (with independent database), I am getting the following error message :

"Attach database failed for Server 'xxx'

Additional Information: An exception occurred while executing a Transact-SQL statement or batch. Could not open new database 'xx'. CREATE Database is aborted. File activation failure. The physical filename "....ldf" may be incorrect. The log cannot be rebuilt because there were open transactions/users when the database was shutdown, no checkpoint occurred to the database, or the database was read-only."

The problem here is we don't have the .ldf file and on trying to attach the .mdf file we are getting the above error message. Is the content db corrupted? if so is there any way by which we can only restore the content DB in SQL, since we don't have another copy and only this file?

ThankYou

1

The issue caused because the missing LDF file, i would suggest to use ATTACH_FORCE_REBUILD_LOG to force rebuild the log file

USE master
GO
CREATE DATABASE <NAME>
ON (FILENAME = 'MDF FILE PATH')
FOR ATTACH_FORCE_REBUILD_LOG

try and let us know if this solves your issue.

0

When attaching your database and it indicates that it cannot find the LDF in the attach dialog box, you need to highlight and remove the LDF. SQL will then create an LDF for you during the attach process.

https://www.mssqltips.com/sqlservertip/1894/attach-a-sql-server-database-with-a-missing-transaction-log-file/

  • Trevor, I already did that and I'm getting the above error message after removing the ldf file. There seems to be some problem with SQL creating the ldf file. Does this mean that there's something wrong with the mdf file? – Hank Jun 9 '18 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.