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
 General SQL Server Forums
 Data Corruption Issues
 how to restore MDF files

Author  Topic 

chanduraag
Starting Member

14 Posts

Posted - 2013-04-18 : 09:12:01
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

819 Posts

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

chadmat
The Chadinator

1974 Posts

Posted - 2013-04-18 : 13:27:13
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

52326 Posts

Posted - 2013-08-05 : 07:38:04
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

212 Posts

Posted - 2013-08-13 : 04:50:38
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

7 Posts

Posted - 2013-08-30 : 06:19:31
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

7 Posts

Posted - 2013-11-27 : 05:10:03
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

4 Posts

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

Houssine
Starting Member

15 Posts

Posted - 2014-01-31 : 04:50:39
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.
Go to Top of Page

elliswhite
Starting Member

36 Posts

Posted - 2014-05-01 : 06:42:58
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

1 Post

Posted - 2014-05-14 : 06:37:56
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

12 Posts

Posted - 2014-07-10 : 06:05:06
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!
Go to Top of Page

Shanky
Yak Posting Veteran

84 Posts

Posted - 2014-07-16 : 07:09:54
===================================
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
Go to Top of Page
   

- Advertisement -