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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS SQL Script

Status
Not open for further replies.

twdave

IS-IT--Management
Feb 18, 2004
32
0
0
US
I have 500+ SQL databases to move to a new server. They are being copied from old server to new via DoubleTake. Once this copy process is over all databases need to be attached on the new server. I'm looking for a fairly easy method of doing this.

I have a script that Icreated a while back that will attach multiple databases in one script execution. The script is antiquated, so a new one is needed. The script reads as a series of statements like:

EXEC sp_attach_db @dbname = N'D3DEMO',
@filename1 = N'D:\DEFAULTSQL\MSSQL\Data\D3DEMO_Data.MDF',
@filename2 = N'E:\DEFAULTSQLLOGS\D3DEMO_log.ldf'

Unless someone know a much easier way, my plan is this:

1. Using CMD - Export MDF directory structure to a text file.
2. Using CMD - Export LDF directory structure to a text file
3. Put the output results into an Excel file - two columns.
4. Create the text for the EXEC statment, as seen above
5. Merge the columns to have the MDF and LDF files placed correctly and the script format as needed

With all that said, can someone think of a way to merge all of this information into a text file that I can run as a script? Macro? Something?

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top