From:       To:      
Home > Documentation > DB2 to SQL Server

Command line version of DB2 to SQL Server converter

To perform batch conversion or call the tool from an automation script you can use console version of DB2 to SQL Server converter called B2MAGENT.EXE. Find this program in the installation folder. B2MAGENT.EXE supports the following parameters:

--db2pswd=...   DB2 user password
--db2schema=...   DB2 schema name
--db2user=...   DB2 user name
--dest=...   SQL Server database or T-SQL script file
--dump   export IBM DB2 database into T-SQL script
--help   display help message and exit
--logfile=...   path to the logfile where execution traces will be written
--mode=...   how to process existing SQL Server database (0 - overwrite the entire database, 1 - overwrite existing tables only, 2 - skip existing tables, 3 - merge)
--mssqlh=...   SQL Server IP address or network name
--mssqlu=...   SQL Server user name
--mssqlp=...   SQL Server password
--profile=...   path to the file to load conversion settings from
--silent   use this option to disable program output
--skip_idx   skip converting indexes
--src=...   IBM DB2 database name
--tab_def   convert table definitions only
--tab_file=...   file containing table names to convert (one table name per line)

In the following example the program converts all tables from tablespace "SYSTOOLS" of local DB2 database "db 1" into SQL Server database "db_mss":

B2PAGENT.EXE --src="db 1" --db2schema=SYSTOOLS --db2user=scott --db2pswd=tiger 
             --dest=db_mss 

Table names file should be formatted as follows:

Table_1
Table_2
...
Table_N

Notes:

  1. If you specified a profile, there is no need to specify any other parameters
  2. The default mode is 'overwrite'. You can change it using '--mode' parameter
  3. You can omit 'mssqlh' parameter to connect local SQL Server
  4. If you omit 'tab_file' parameter, all tables from the specified schema will be converted
  5. Command line parameters that contain spaces should be enclosed in quotes (for example --dest="my database")