Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 How To Recover Data From A Corrupt Mdf File?

Author  Topic 

PhilipRod
Starting Member

1 Post

Posted - 2014-09-22 : 08:12:40
Hi All,
By mistake i delete database from sql server. Due to which the the mdf and ldf file of the datbase are removed from my system. Then i used file recover utility and retrived my mdf and ldf files.But now i am not able to attach those files into databse. These mdf and ldf files has been corrupted. Now how can i recover my data from those mdf and ldf files.Please answer me if you have any solution on this problem.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-22 : 12:54:15
Restore the database using RESTORE DATABASE command. You'll need to reference your last SQL Server backup, likely bak extension.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

BrandMon
Starting Member

2 Posts

Posted - 2014-09-24 : 13:02:18
When you try to attach a MDF database to SQL Server and get the error "xxx.mdf is not a primary database file", then for most of the cases, that means your MDF file is corrupt or damaged.

There are two possible solutions based on the situation:

If the corruption is not severe, then you can use the SQL Server build-in command DBCC CheckDB to correct the errors.
SQL Server Recovery Toolbox is powerful MS SQL MDF recovery tool, providing a reliable protection for database administrators. The highest efficiency of SQL database restoration program allows offering the following advantages for all users:

Works with databases that consist from several files, mdf and ndf;
Flexible, easy and friendly interface, guiding database administrators through all steps of repair;
Fixes data types, tables, views, stored functions and procedures, triggers, indexes, restrictions and keys;
Fully compatible with Windows 7 and earlier versions of this OS;

unspammed

As you can look for the answer here: http://www.filerepairforum.com/forum/databases/databases-aa/mysql/191-myfilename-mdf-is-not-a-primary-database-file-does-it-mean-the-file-is-corrupted
Hope this will help. Good luck!
Go to Top of Page

clubshrivel
Starting Member

4 Posts

Posted - 2014-10-07 : 21:58:55
Thanks for the post, I really need this information, this will help alot. :)
Go to Top of Page
   

- Advertisement -