0

My client's SQL Server database file is corrupted, and there is no backup. We only found the MDF and LDF files copied using NAT backup software. I need to use these files to rebuild the database. The issue is that I cannot attach the MDF file. The reported error is...

The error message indicates that the database attachment failed for server 'SERVER\SSQ' due to a Transaction-SQL statement or batch execution issue. Specifically, the database 'BeeGSS' cannot be opened because it is marked as 'CREATE DATABASE' and the operation was aborted. This is because the transaction log file 'E:\DATABASE\BeeGSS_Log.LDF' could not be rebuilt, likely due to open transactions when the database was shut down, manual deletion of the log file, or a hardware/environmental failure. To resolve this, you may need to verify the database state, ensure no transactions are open, and restore or recreate the transaction log file.

How can I solve this?

3
  • If this is a self answered question, then add a proper question, and add a proper answer. Commented May 20 at 2:07
  • Please quote errors verbatim rather than editing it. Commented May 20 at 2:12
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented May 20 at 15:38

1 Answer 1

2

Since I couldn’t attach the database, I used an alternative method:

  • Created a new database with the same name and matching MDF and LDF file names.
  • Took the new database offline.
  • Overwrote the new database files with the MDF and LDF files you want to attach.
  • Took the database online (with a lot of errors, of course).
  • Executed the following commands:
ALTER DATABASE [DatabaseName] SET EMERGENCY;
GO
ALTER DATABASE [DatabaseName] SET SINGLE_USER;
GO
DBCC CHECKDB ('DatabaseName', REPAIR_ALLOW_DATA_LOSS);
GO
ALTER DATABASE [DatabaseName] SET MULTI_USER;
GO
ALTER DATABASE [DatabaseName] SET ONLINE;
GO
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.