SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Data Corruption Issues
 how to restore MDF files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chanduraag
Starting Member

India
14 Posts

Posted - 04/18/2013 :  09:12:01  Show Profile  Reply with Quote
Hi DBA World,

i am new to this field,i got an issue of restoring MDF files.

please tell me how to restore the MDF files.


thanks in advance

jeffw8713
Aged Yak Warrior

USA
790 Posts

Posted - 04/18/2013 :  13:08:02  Show Profile  Reply with Quote
You restore a database from a backup - you don't restore mdf files.
Go to Top of Page

chadmat
The Chadinator

USA
1974 Posts

Posted - 04/18/2013 :  13:27:13  Show Profile  Visit chadmat's Homepage  Reply with Quote
As Jeff said, you don't restore MDF files. You may be able to attach it however.

-Chad
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 08/05/2013 :  07:38:04  Show Profile  Reply with Quote
quote:
Originally posted by chanduraag

Hi DBA World,

i am new to this field,i got an issue of restoring MDF files.

please tell me how to restore the MDF files.


thanks in advance


you just need to logon to the server where you want database to be included then use attach option and browse to path where you've mdf file.
Make sure your server instance is of same version or above as the server from which mdf file was created.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

prett
Posting Yak Master

USA
192 Posts

Posted - 08/13/2013 :  04:50:38  Show Profile  Visit prett's Homepage  Reply with Quote
As mentioned above you can't restore mdf file. You can attach it. A database can be attached by following methods:
1. SQL server management studio (SSMS)
2. Transact SQL (T-SQL)
3. sp_attach_db stored procedure.
Go to Top of Page

rodyroon
Starting Member

6 Posts

Posted - 08/30/2013 :  06:19:31  Show Profile  Reply with Quote
Hello,

I am also agree with jeffw8713 You can restore a database from a backup not MDF files. If You have corruption issue in your MDF Files then I can provide you an excellent SQL recovery software which can very easily repair your corrupted MDF Files, This effective application is Kernel for SQL Recovery Tool that repairs all kind of damaged MDF files of SQL Server database. You can also try it may be it help you.
Go to Top of Page

Paul J. Brooks
Starting Member

USA
7 Posts

Posted - 11/27/2013 :  05:10:03  Show Profile  Reply with Quote
Yes,This is a serious problem but i m stranger with this field.so i wanna discus on this topic.anyone interested then reply me.i m waiting.

unspammed
Go to Top of Page

pearlpet26
Starting Member

India
4 Posts

Posted - 01/29/2014 :  04:58:36  Show Profile  Reply with Quote
I used Kernel Software which worked me successfully. Have a look here unspammed
Go to Top of Page

Houssine
Starting Member

USA
4 Posts

Posted - 01/31/2014 :  04:50:39  Show Profile  Reply with Quote
quote:
Originally posted by chanduraag
i am new to this field,i got an issue of restoring MDF files.

please tell me how to restore the MDF files.


Are you trying to restore the MDF files from a backup file? If you are having problem in restoration, this means your BKF file is not valid. You need to repair the BKF file or you need to recover your data from it. Or if your MDF files are corrupted and you want to restore your data from them, you need to repair it by using a 3rd party tool.
Try any of these: "SysInfoTools Backup Exec BKF Repair Pro" or "SysInfoTools MS SQL Database Recovery".

You may try free demo versions of these software before buying full version.
Thanks.

Edited by - Houssine on 02/11/2014 06:25:03
Go to Top of Page

elliswhite
Starting Member

36 Posts

Posted - 05/01/2014 :  06:42:58  Show Profile  Reply with Quote
There are two methods to attach MDF file
• Through SSMS
• By running T-SQL Script

Method - 1

1) Open SSMS & connect SQL Server
2) Go Local SQL Server -> Databases
3) Right click to select attach option
4) “Add” option to select MDF file
5) Click “ok”

Method – 2

CREATE DATABASE Test
ON (FILENAME = 'C:\MsSQLServer\abc.mdf'),
(FILENAME = 'C:\MsSQLServer\abc_Log.ldf')
FOR ATTACH;
Go to Top of Page

ORLOVA
Starting Member

India
1 Posts

Posted - 05/14/2014 :  06:37:56  Show Profile  Reply with Quote
I use the following way to do it:
1. I create DB named TEST
2. I copy the MDF to the location d:dataTEST1_DATA.MDF
3. exec sp_detach_db @dbname='TEST'
exec sp_attach_single_file_db @dbname='TEST',
@physname='d:dataTEST1_DATA.MDF'

then I got error message: "Create Database aborted. Device aviation error. 'd:mssqldataTEST1_LOG.LDF' maybe incorrect.


[url=http://himachalvolvotour.com/online-bus-booking.php]Delhi to manali volvo bus booking[/url]
Go to Top of Page

bakk
Starting Member

6 Posts

Posted - 07/10/2014 :  06:05:06  Show Profile  Reply with Quote
Hi chanduraag!

Did you try CHECKDB statements to restore MDF file?
These are the dbcc statements which scans and fixes the corruption in MDF file.
Statements are:

EXEC sp_resetstatus database_name;
ALTER DATABASE database_name SET EMERGENCY
DBCC checkdb (database_name)
ALTER DATABASE database_name SET SINGLE_USER with ROLLBACK IMMEDIATE
DBCC DATABASE (database_name, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE database_name SET MULTI_USER

You can check this solution in detail by visiting blog post: http://nalavadebela.wordpress.com/2014/04/05/how-to-repair-corrupt-mdf-file-of-microsoft-sql-server

It will resolve your issue!

Edited by - bakk on 07/10/2014 06:06:19
Go to Top of Page

Shanky
Starting Member

United Kingdom
24 Posts

Posted - 07/16/2014 :  07:09:54  Show Profile  Reply with Quote
===================================
EXEC sp_resetstatus database_name;
ALTER DATABASE database_name SET EMERGENCY
DBCC checkdb (database_name)
ALTER DATABASE database_name SET SINGLE_USER with ROLLBACK IMMEDIATE
DBCC DATABASE (database_name, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE database_name SET MULTI_USER

You can check this solution in detail by visiting blog post: http://nalavadebela.wordpress.com/2014/04/05/how-to-repair-corrupt-mdf-file-of-microsoft-sql-server

It will resolve your issue!
[/quote]
===========================================
NOO its not guaranteed to resolve the issue. It depends on level of corruption. repair allow data loss might delete as much data as possible to remove corruption and that too without informing do b cautious

Regards
Shanky
http://social.technet.microsoft.com/wiki/contents/articles/24253.list-of-articles-by-shanky.aspx

Edited by - Shanky on 07/16/2014 07:10:37
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000