Create Database from only .MDF file

Posted by Professionaluser under Sql Server category on | Points: 40 | Views : 856
I had a scenario where wanted to create database from single /MDF file and do not have .LDF file. I tried to create new database by using attach, restore databases, restore Files and Filegroups options; These options caused some other issues.

The below single and simple query resolved all the issues in my case,
EXEC sp_attach_single_file_db @dbname='AdventureWorks2012' ,@physname='C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\AdventureWorks2012_Data.mdf'

Comments or Responses

Login to post response