SQL: Attach a database using a different database name

When attaching a database in SQL Server using the interface, it doesn’t let you change the name of the destination database. This can be done using the SQL Commands below.

USE [master]
GO
CREATE DATABASE [myNewSite_db] ON
( FILENAME = N'D:\Data\myNewSite_db.mdf' ),
( FILENAME = N'E:\Logs\myNewSite_db_log.ldf' )
FOR ATTACH
GO

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *