Ispirer Website Ispirer Toolkit Overview Free Trial

How to Convert and Import Database in Command Line Mode

Ispirer Toolkit allows you to convert and load converted database via command line or shell script.

First of all we need to open a command line window by running Start → Run → cmd.exe


Preparing Command Line

To convert database objects we need to use sqlways.exe command line utility. So we have to prepare appropriate command line for this command line tool.

Command line may look as follows:

   "C:\Program Files\Ispirer\IspirerToolkit10\sqlways.exe" /IMPORD=Fast /D=ASE15.7_CONNECT1 /U=user1 /P=pwd1 /SROW=1 /DIR="S:\Work\TEMP_OJ\Datamigration\ASE2MSSQL\Export" /LOG=sqlways.log /TARGET=Microsoft SQL Server /NSTOP /TRACE /RPT=reports /PRJF="S:\Work\TEMP_OJ\Datamigration\ASE2MSSQL\sqlways.xml" /INI="S:\Work\TEMP_OJ\Datamigration\ASE2MSSQL\sqlways_db.ini" /TD=Zhyrava /TH=servername1 /TP=pwd1 /TU=uuser1

Note: SQLWays command line options are case insensitive and their order is insignificant.


Here is the list of parameters used in the provided command line:

  • sqlways.exe - this is the name of the utility that performs the conversion. If required it can be specified with the full path to the utility.
  • /D - specifies the ODBC Data Source Name (DSN) to connect to the source database. Articles on how to tune the ODBC Connection to your source database can be found in the Database: Setup and Troubleshooting section for corresponding source database.
  • /IMPORD - import order for tables
  • /U - specifies the user name for the source connection.
  • /P - specifies the password for the source connection.
  • /SROW - specifies the start row
  • /DIR - specifies the location of the generated files (output directory).
  • /LOG - specifies the name of the conversion log file.
  • /TARGET - specifies the target database.
  • /NSTOP - specified that process should be continue when an error occurs
  • /TRACE - specifies the trace mode
  • /RPT - specifies the report file name
  • /PRJF - specifies the path to the project file. In this file information about the objects specified for conversion is stored. You can find more information about the project file here.
  • /INI - specifies the options file. Options file is a file that stores all the options supported by the tool. Options file with the default settings is located in the directory like: “C:\Users\[user_name]\Documents\Ispirer\SQLWays 10\”. You can use it as a default options file. More information about the supported options can be found here.
  • /TD - specifies the target database name, where import should be done.
  • /TH - specifies the target host\server name.
  • /TP - specifies the password that will be used to connect to the target database.
  • /TU - specifies the user name for the target connection.


Filtering and Selecting Objects

These parameters allow you to select specific objects or patterns for conversion.


/T= — Convert Tables

Value Description
/T=schema.tablename Convert a specific table.
/T=“dbo_2.*” Convert all tables from schema `dbo_2`.
/T=*.* Convert all tables in all schemas.

/SP= — Convert Stored Procedures by Name or Pattern

Value Description
/SP=dbo.proc_name Convert one specific procedure.
/SP=dbo.test_* Convert all procedures starting with `test_` in schema `dbo`.

/O= — Convert All Object Types

Value Description
/O=*.* Convert all object types: tables, procedures, functions, triggers, etc.

/S= — Convert from Custom SQL SELECT Statement

Value Description
/S=SELECT * FROM Tab1 Converts the table definition and exports data based on the result of the SELECT query.


More details could be found here.


Easiest Way to Get Command Line

The easiest way to prepare correct command line is to run the SQLWays tool, select all the required objects for conversion and on the “Summary” page, you will see the generated command line:

You can just copy the generated command line and run it.


Running Prepared Command Line

After we prepared the command line with appropriate set of options we need to run it in the command line prompt.

And as a result, in the output directory we will see all generated scripts.

Thus the conversion process is finished.


During the Conversion process, the SQLWays.exe tool generates not only all the scripts needed to import the objects, but also some additional files: “import_data” and “sqlways_imp_cmd.txt”:

The “import_data” file contains attributes for import process performing:

The “sqlways_imp_cmd.txt” file contains the command line, which could be used for running of import via command line window.


Sample of the command line:

   "C:/Program Files/Ispirer/SQLWaysToolkit10\DBImport.exe" 
   /DATA="S:\ExportDirectories\SybaseASE_MSSQL\TestConnect\Export\import_data" /ARG=all; /TRACE /RPT /RPT_DIR=reports

Here is the list of parameters used in the provided command line:

  • DBImport.exe - this is the name of the utility that performs the import. If required it can be specified with the full path to the utility.
  • /DATA - specifies the path to the folder containing the exported data files. These files will be used for import into the target database.
  • /ARG - indicates that all available objects and data in the specified directory should be imported. The all value is a fixed keyword instructing the tool to process everything.
  • /TRACE - enables tracing. This option generates a detailed log of the import process.
  • /RPT - enables report generation. The tool will produce summary and detailed reports about the import process.
  • /RPT_DIR - specifies the directory name where the generated reports will be saved.

More details could be found here.


During the Import process, the DBImport.exe tool uses this generated file “import_data” for import objects to Target database.

To perform the import from Command line window, we need to go to the Export directory, open the file sqlways_imp_cmd.txt, copy the command line, which was created during Conversion process and run this command line.

Please see the screenshot for reference:

A more detailed list of command line options can be found here.

The /ARG parameter in the DBImport.exe command specifies which types of objects should be imported into the target database. It accepts a semicolon-separated list of object categories. This allows for granular control over the import process.

Syntax:

   /ARG=<object_type1>;<object_type2>;...;<object_typeN>;

Available Object Types:

Object Type Description
table Imports tables. Only table definitions are imported.
import Imports exported data (rows) into tables.
cns Imports constraints such as primary keys, foreign keys, unique constraints, etc.
idx Imports indexes for tables.
view Imports views, including their definitions and dependencies.
business_logic_object Imports business logic objects such as stored procedures, functions, and packages.
trigger Imports triggers associated with tables or views.
sequence Imports sequences, used for generating auto-increment values.
user_defined_type Imports user-defined types (UDTs), including domain definitions or custom types.
synonym Imports synonyms used to reference database objects under alternate names.
generated_objects Imports automatically generated support objects, often required to simulate functionality from the source DB.
all Imports all objects that were previously converted by Ispirer Toolkit. This is a shortcut and includes every supported category.

Examples:

Import all objects except indexes and user-defined types:

   "C:/Program Files/Ispirer/IspirerToolkit10/DBImport.exe" /DATA="..." /ARG=table;import;cns;view;business_logic_object;trigger;sequence;synonym;generated_objects; /TRACE /RPT /RPT_DIR=reports

Import everything except sequences and data:

   "C:/Program Files/Ispirer/IspirerToolkit10/DBImport.exe" /DATA="..." /ARG=table;cns;idx;view;business_logic_object;trigger;user_defined_type;synonym;generated_objects; /TRACE /RPT /RPT_DIR=reports

Import all converted objects:

   "C:/Program Files/Ispirer/IspirerToolkit10/DBImport.exe" /DATA="..." /ARG=all; /TRACE /RPT /RPT_DIR=reports


If you have questions about how to run the migration in batch mode, please contact our technical team at support@ispirer.com