restoring database from mdf file in sql server

11
RESTORING DATABASE FROM MDF FILE

Upload: jasonclark03

Post on 20-Jan-2017

285 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Restoring Database From MDF File in SQL Server

RESTORING DATABASE FROM MDF FILE

Page 2: Restoring Database From MDF File in SQL Server

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

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

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

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

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

Go to Attach option Right click on the ‘Databases‘ and click on

‘Attach‘

Page 8: Restoring Database From MDF File in SQL Server

Attaching Database In Attach Databases dialog box Click on ‘Add…‘ button

Page 9: Restoring Database From MDF File in SQL Server

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

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

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