HP StorageWorks Storage Mirroring application notes (T5437-96014, December 2009)
1. Using Notepad or any text file editor, create a SQL command file and save it with a .sql exten-
sion. The file will utilize the stored procedure sp_attach_db. The following sample file illustrates
the command syntax for attaching three sample databases, named Sales, Accounting, and
Marketing. Note that the complete path and filespec to the database and corresponding log files
on the target must be included. Refer to the file paths recorded in
“Install software on the target” on page 8.
NOTE:
These sample batch files are available on the Double-Take Software support website at
http://support.doubletake.com. After you modify the sample scripts, save them with a new name
to remove the sample_ prefix. Copy the scripts to the directory where Storage Mirroring is
installed. The sample batch files provided are only examples. Because no two environments or
configurations are exactly the same, you MUST modify the sample scripts in order to make the
solution work in your environment.
SAMPLE_AttachDB.sql
-- ***SAMPLE*** commands for attaching the SQL databases to the target server using Query
-- Analyzer or the OSQL command line utilty.
-- This sample file is provided as an example only. Because no two environments or
-- configurations are exactly the same, you MUST modify this file in order to make the
-- solution work in your environment.
-- This example shows divergent paths on the target server for the various databases and
-- corresponding transaction logs.
EXEC sp_attach_db 'Sales',
'S:\Program Files\Microsoft SQL Server\MSSQL\Data\Sales_Data.MDF',
'L:\Program Files\Microsoft SQL Server\MSSQL\Data\Sales_Log.LDF'
EXEC sp_attach_db 'Accounting',
'T:\Program Files\Microsoft SQL Server\MSSQL\Data\Accounting_Data.MDF',
'L:\Program Files\Microsoft SQL Server\MSSQL\Data\Accounting_Log.LDF'
EXEC sp_attach_db 'Marketing',
'M:\Program Files\Microsoft SQL Server\MSSQL\Data\Marketing_Data.MDF',
'L:\Program Files\Microsoft SQL Server\MSSQL\Data\Marketing_Log.LDF'
2. Create a batch file on the target to execute sqlcmd using the AttachDB command file created
above as an input file. The following sample file illustrates the correct syntax.
SAMPLE_AttachSQL.bat
rem ***SAMPLE*** script for attaching SQL databases.
rem This sample file is provided as an example only. Because no two environments or
rem configurations are exactly the same, you MUST modify this file in order to make the
rem solution work in your environment.
rem In the following command, replace the path with the complete path to your SQL AttachDB.sql
rem command file. You may also need to specify the path to the sqlcmd utility.
sqlcmd -E -I -i "C:\SQL Scripts\AttachDB.sql"
NOTE:
The complete path to the command file (.sql) created above must be included.
3. Run the AttachSQL.bat file on the target server. The account running the .bat file must be a
member of the sysadmin or dbcreator fixed server roles.
HP StorageWorks Storage Mirroring application notes 11