About My Work

Attaching Database to SQL Server 2005

Posted by: paolyn lazo on: September 1, 2008

For those people who are looking for a script to be able to attach database to sql server 2005 here is a sample script:

USE [master]

GO

CREATE DATABASE [AdventureWorksDW] ON

(FILENAME = N’D:\files\databases\adventureworksBW\AdventureWorksDWData.mdf’ ),

(FILENAME = N’D:\files\databases\adventureworksBW\AdventureWorksDWLog.ldf’ )

FOR ATTACH ;

GO

or simply:

USE [master]

GO

CREATE DATABASE [database name] ON

(FILENAME = N’[path\filename.mdf]‘ ),

(FILENAME = N’[path\filename.ldf]‘ )

FOR ATTACH ;

GO

the following [] should be replaced, .mdf is the primary file while .ldf s the log file

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


  • paolynlazo: yeah its for initial migration! Thanks!
  • Naveen: Please notify me when new post added.
  • rnm1978: Be careful with migrating your whole webcat folder. Dashboards and reports that users have created in your destination environment may get overwritten

Categories

Follow

Get every new post delivered to your Inbox.