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
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