I’m dealing with a corrupted SQL Server database situation where I only have MDF and LDF files from a client (no proper backup available). These files were recovered using NAT backup software.
When I try to attach the MDF file, I get an error saying the database can’t be opened because it’s stuck in CREATE DATABASE state. The system reports that the transaction log file cannot be rebuilt, possibly due to active transactions during shutdown or log file corruption.
The specific database name is ‘BeeGSS’ and the error mentions issues with rebuilding the LDF file. I suspect this happened because of improper shutdown or hardware problems.
What’s the best approach to recover this database? Should I try to rebuild just from the MDF file or is there a way to repair the existing LDF?
Try ATTACH_REBUILD_LOG before going nuclear with emergency mode. Just run CREATE DATABASE BeeGSS ON (FILENAME = 'path\to\your.mdf') FOR ATTACH_REBUILD_LOG - it’ll ditch the old ldf and create a new one. Fixed this exact issue for me a couple times when clients brought similar messes.
Recovering corrupted MDF files can indeed pose challenges. Given that your database is in a CREATE DATABASE state, attempting a standard attach won’t suffice. I recommend using SQL Server’s emergency mode. Create a new database named ‘BeeGSS’, stop SQL Server, replace the new MDF with your corrupted one, and then restart the service. Set the database to emergency mode using ALTER DATABASE BeeGSS SET EMERGENCY, followed by DBCC CHECKDB with appropriate repair options. While some data loss may occur, this method has proven effective in salvaging the majority of data when other solutions fail.
that’s a tough spot! have you checked if the MDF file is actually readable before tryin g emergency mode? run DBCC CHECKDB on just the MDF - it’ll show you how bad the corruption really is. what sql server version are you using? older versions handle this stuff differently than newer ones.