Sql-server – Port SQL Server data to MySQL without Workbench

MySQLmysql-workbenchsql server

When using MySQL Workbench to migrate data from SQL Server to MySQL I ran into a bug that it won't escape apostrophes. In the interim I would like to still port that data over. Is there any simple way to do this?

I've exported my data into a file with INSERT statements but they don't match the syntax of MySQL (I'm new to MySQL) so I don't know if it would work, neither does the file contain semicolons at the end of each statement.

Thanks in advance.

Update

So, far it looks like the easiest way to do it is to export the data into flat files and go through each table and make sure to also generate a SSIS file that you can use to automate future exports. Like so:

 DTExec /File MyExportedSissFileForOneTable.dtsx

And then use PowerShell or some other scripting language to do all the different files you need to update. Then import the files with MySQL – which I haven't figured out yet.

Best Answer

In retrospect it is probably nicer to just roll my own converter since MySQL uses snake case instead of title case like SQL Server.

So, what I'm going to do is use a PowerShell script like so:

$tables = "FirstTable", "SecondTable"
function script {
    param(
        [System.String] $table
    )
    "set nocount on; select * from dbo."+$table
}

$tables |
% {
   $path = "C:\Data\"+$_+".txt"
   $script = script $_
   sqlcmd -S MyServer -d MyDatabase -W -h -1 -E -Q $script -s `"`t`" -o $path
}

This will export all the data from my SQL Server database and put them in files and then I will import those files into MySQL. Which I haven't quite figured out yet. I let the MySQL Workbench do the initial CREATE TABLE statements and used Vim to make everything snake case.