Ispirer Website
Ispirer Toolkit Overview
Free Trial
Using SQL scripts before and after migration
As part of the improved functionality of the data migration tool, two optional options have been added that will allow you to manage the data import process more flexibly by automating pre- and post-import operations. They allow you to specify SQL scripts to be executed before and after data import. This article describes the new options and the process of their configuration in detail.
- BEFORE_IMPORT_SCRIPT - The path to the SQL script that will be executed before importing all objects.
- AFTER_IMPORT_SCRIPT - The path to the SQL script that will be executed after the import of all objects is completed.
Setting
To use the new options, you must add the appropriate SQL script paths to the configuration file (sqlways_db.ini). Configuration examples:
[COMMON] BEFORE_IMPORT_SCRIPT = C:\doc\before_sql_file.sql AFTER_IMPORT_SCRIPT = C:\doc\after_sql_file.sql
The process of creating bat files
If the BEFORE_IMPORT_SCRIPT and/or AFTER_IMPORT_SCRIPT settings are present, the tool will create the appropriate bat files:
- before_import_script.bat for the script specified in BEFORE_IMPORT_SCRIPT
- after_import_script.bat for the script specified in AFTER_IMPORT_SCRIPT
The bat files will execute the SQL scripts specified in the settings. To execute the scripts correctly, the bat files will support paths with spaces and any custom encodings.
Examples of bat files content: before_import_script.bat:
- before_import_script.bat:
@echo off sqlcmd -S <ServerName> -d <DatabaseName> -i "C:\doc\before_sql_file.sql"
- after_import_script.bat:
@echo off sqlcmd -S <ServerName> -d <DatabaseName> -i "C:\doc\after_sql_file.sql"
Error handling
If errors occur during script execution, they will be displayed in the import log in the same way as for any other objects. This makes it easy to track and diagnose problems that may occur during script execution.
Note that if BEFORE_IMPORT_SCRIPT or AFTER_IMPORT_SCRIPT options are absent or their values are empty, the corresponding bat-files will not be created.
The options are also independent of each other: if one of the options is missing, no bat-file will be created for it, but a bat-file will be created for the present option.
Related Topics
How to Run Ispirer SQLWays Wizard in Parallel Mode
If you have any questions or face any difficulties, please contact our support team at support@ispirer.com