Sunday, October 25, 2015

Create a New SQL Server Database basing from a renamed DB (mdf/ldf) files

I recently created a copy of Northwind database and called it NorthwindBootstrap. This database has a built-in membership tables added to it. The copy includes both of mdf and ldf files. My next step is to create a new database based from the recently copied/renamed files in which I have no idea on how to do it.
After doing some research, I stumbled upon a t-sql script based from my requirement.
 USE [master]  
 GO  
 CREATE DATABASE [NorthwindBootstrap] ON   
 ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\NorthwindBootstrap.mdf' ),  
 ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\NorthwindBootstrap.ldf' )  
 FOR ATTACH  
 GO  

Cheers! :)

0 comments:

Post a Comment