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