SQL SERVER : Create database from .MDF & .LDF file | ASPMANTRA | Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server AND WCF snippets and tutorial

SQL SERVER : Create database from .MDF & .LDF file

In this article I am going to explain how to create database from .MDF & .LDF file in Sql server.

Description & Implementation:
I have .MDF and .LDF file of database. I want to restore or create database from these files. We have 2 ways to create database from .MDF and .LDF file.

Method 1: Using  T-Sql
Run the below given query :

CREATE DATABASE aspmantra ON
(FILENAME = 'F:\Project\resthour\aspmantra.mdf'),
(FILENAME = 'F:\Project\resthour\aspmantra_log.ldf')
for attach;


Method 2: Using Sql server Management studio (SSMS)
Follow the below given steps to create database from MDF file.

Step 1: Login to Sql server database engine. Right click on database and select the Attach. See attachment

SQL SERVER : Create database from .MDF & .LDF file



Step 2: Attach database pop up window will be open. Click on add button.

SQL SERVER : Create database from .MDF & .LDF file



Step 3: Locate database files window will be open. Select the MDF file and press the Ok button.


SQL SERVER : Create database from .MDF & .LDF file




SQL SERVER : Create database from .MDF & .LDF file





Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget