restoring database from mdf file in sql server
TRANSCRIPT
![Page 1: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/1.jpg)
RESTORING DATABASE FROM MDF FILE
![Page 2: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/2.jpg)
Index View Of Topics
Introduction Methods to Restore SQL Database Attach Database using Management
Studio Open Management Studio Go to Attach option Attaching Database Locating .mdf File Attach Database using T-SQL Conclusion
![Page 3: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/3.jpg)
Introduction
The SQL Server provides the facility to restore your database by attaching your .mdf file to the database.
You can directly Attach your existing .mdf file to an SQL instance by using SQL Server Management Studio or T-SQL.
![Page 4: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/4.jpg)
Methods to Restore SQL Database
SQL Server provides two different methods for attaching your .mdf file with your database
1. Attach Database using Management Studio
2. Attach Database using T-SQL
![Page 5: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/5.jpg)
Attach Database using Management Studio Choose a server from your network. Set the
Authentication mode to “Windows Authentication” and click on “Connect” button.
![Page 6: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/6.jpg)
Open Management Studio Once logged in, In Object Explorer, Double
click on the ‘Databases’ to see the existing databases within the SQL instance.
![Page 7: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/7.jpg)
Go to Attach option Right click on the ‘Databases‘ and click on
‘Attach‘
![Page 8: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/8.jpg)
Attaching Database In Attach Databases dialog box Click on ‘Add…‘ button
![Page 9: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/9.jpg)
Locating .mdf File Now, locate the .mdf file, which is to be add
and click on “OK”.
![Page 10: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/10.jpg)
Attach Database using T-SQL
Take a New Query window using Management Studio and write the below code and click on “Execute”
CREATE DATABASE fixed_data ON (FILENAME = 'c:\data files\fixed_data.mdf'), (FILENAME = ' c:\data files\fixed_data.ldf') FOR ATTACH;
![Page 11: Restoring Database From MDF File in SQL Server](https://reader036.vdocument.in/reader036/viewer/2022082619/58813bd71a28abf65a8b54c1/html5/thumbnails/11.jpg)
Conclusion
Both the procedures helps in attaching .mdf file to the database or restore an existing database from MDF file.
If you are still facing problem in restoring database from MDF file you can go through this:
http://www.systoolsgroup.com/sql-recovery/how-it- works.html