Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

Thanks.

share|improve this question

migrated from serverfault.com Nov 23 '11 at 12:59

This question came from our site for professional system and network administrators.

3 Answers 3

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.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer
3  
+1 If the data is valuable enough, there is always a way to get some, if not all of it back. Unbelievable tale of disaster and recovery is a good example of what's possible. –  Mark Storey-Smith Nov 23 '11 at 14:34
    
If data is valuable enough there would backups, standby servers, tested restores etc. The whole shebang. –  gbn Nov 23 '11 at 16:31
    
@gbn Replace would with should and I 100% agree :) –  Mark Storey-Smith Nov 25 '11 at 10:51
    
@Mark Storey-Smith: english.stackexchange.com/questions/10066/should-versus-would –  gbn Nov 25 '11 at 11:03
1  
@gbn Sorry, wasn't intending to point out a grammatical error, more a semantic one. "Should" (expectation that a backup policy exists) versus "would" (preference for backups having been taken). –  Mark Storey-Smith Nov 25 '11 at 12:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.