We are working on an MDF file that has been corrupted, because a virus deleted 2 MB from the header of the file.

We also have another backup of this MDF File from 3 months ago. Both MDF files have the same size.

I think I can read some of the tables in binary data from the corrupted DB, but I don't know about the structure of MDF files

What's the solution for this?



Your solution here is to restore the database from backup.

If you have transaction log backups you can restore the logs as well. If the database is in simple recovery mode you'll be loosing 3 months worth of data.


It sounds like you have a copy of the MDF file, rather than an actual file generated by BACKUP DATABASE. If so, you have lost 3 months data.

You can try attaching this without log file using

CREATE DATABASE databasenamehere ON (filespechere) FOR ATTACH_REBUILD_LOG

The current MDF is most likely can't be salvaged. Reading the file is impractical

After this, look at MSDN Backup Overview


How valuable is the lost data, how many schema changes have there been in the last three months and what exactly was the nature of the corruption? Some of it may be recoverable if you are prepared to spend sufficient time on the project.

You could download the source code for OrcaMDF as a starting point.


Your Answer

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