Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attach multiple databases

Status
Not open for further replies.

dgillz

Instructor
Mar 2, 2001
10,038
US
I have about 30 database I need to attach to a new server. Is there any way to do this other than one at a time?

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Create a script file, connect to your new server and run it in Query Analyzer.
Code:
EXEC sp_attach_db @dbname = 'yourFirstdb',
        @filename1 = 'C:\yourfolderlocation\yourFirstdb.mdf',
        @filename2 = 'C:\yourfolderlocation\yourFirstdb.ldf'
go

EXEC sp_attach_db @dbname = 'yourSeconddb',
        @filename1 = 'C:\yourfolderlocation\yourSeconddb.mdf',
        @filename2 = 'C:\yourfolderlocation\yourSeconddb.ldf'
go
.
.
.
EXEC sp_attach_db @dbname = 'your30thdb',
        @filename1 = 'C:\yourfolderlocation\your30thdb.mdf',
        @filename2 = 'C:\yourfolderlocation\your30thdb.ldf'
go
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top