Home > Documentation > MySQL to MS SQL

Command line version of MySQL to SQL Server converter

To perform batch conversion or call conversion procedure from an automation script you can use console version of MySQL-to-MSSQL called S2MAGENT.EXE. Find this file in MySQL-to-MSSQL installation folder. You can either run this tool directly from command line or call it from any script as well. The program supports the following command-line options:

--as_dbo   connect to MS SQL server as database owner
--blob2text   convert BLOB to text
--dest=...   MS SQL database name
--help   display help message and exit
--logfile=...   path to the logfile where execution traces will be written
--mode=...   how to process an existing MS SQL database (0 - overwrite the entire database, 1 - overwrite existing tables only, 2 - skip existing tables, 3 - merge, 4 - synchronize)
--mssqlh=...   MS SQL server IP address or network name
--mssqlu=...   MS SQL user name
--mssqlp=...   MS SQL user password
--mysqlh=...   MySQL server IP address or network name
--mysqlu=...   MySQL user name
--mysqlp=...   MySQL user password
--port=...   MySQL port
--script   export MySQL data into T-SQL script file
--silent   use this option to disable program output
--skip_idx   skip converting indexes
--src=...   MySQL database name
--tab_def   convert table definitions only
--tab_file=...   name of the file containing table names to convert (one table name per line)
--views   convert MySQL views into MS SQL

In the following example the program converts MySQL database "db1" on the remote MySQL server "mysqlhost" to local MS SQL database "db1_from_mysql" using table names file "c:\tabfile1.txt":

S2MAGENT.EXE --src=db1 --dest=db1_from_mysql --mysqlh=mysqlhost --mysqlu=administrator 
--mysqlp=the_passsword --tab_file=c:\tabfile1.txt

Table names file should be formatted as follows:

Table_1
Table_2
...
Table_N

Notes:

  1. You can omit 'mssqlh' or 'mysqlh' to connect local database server
  2. You can omit 'mssqlu' and 'mssqlp' parameters to connect to MS SQL server using Windows authentication
  3. It is necessary to specify 'port' parameter only if it differs from the default MySQL port 3306
  4. If you omit 'tab_file' parameter, all database tables will be converted
  5. If you omit 'mode' parameter, default mode 'overwrite the entire database' will be used
  6. Command line parameters that contain spaces should be enclosed in quotes (for example --dest="my database")

Have any questions? Contact us