Click here to Skip to main content
15,887,386 members
Articles / Database Development / SQL Server / SQL Server 2008R2
Tip/Trick

MSSQL to MySQL Export

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
16 Apr 2014CPOL 11.4K   30   5   4
Converting MSSQL database to MySQL

Introduction

This piece of code aims to export or convert MSSQL database to MySQL database.

It can be achieved with third party apps.

I'm not very proud of my code, it can be improved but it worked for me.

Background

There are 4 files:

  1. Batch to execute SQLCMD
  2. Table schema export
  3. Data export
  4. FK Export
This script uses information schema to get table/columns information.

It can be customized as you want.

Using the Code

Just update information in .bat file:

C++
rem variables de connexion SQL
set host= your_host (local) or IP,PORT
set schema= your_schema
set user= your_user
set pass= your_password 

Then execute (cmd or click).

3 files are created:

  • tables.sql which contains table definitions
  • data.sql which contains data
  • fk.sql for fk
You will have to do a regex replace (with Notepad++):
  • on table.sql: replace ",\r\n\r\n)" by "\r\n\r\n)"
  • on data.sql: replace ",\r\n\r\n/" by ";\r\n\r\n/"

Points of Interest

My code is a little ugly, but the most interesting thing was to investigate into INFORMATIONS_SCHEMA on MSSQL, and the way to produce another SQL script for MySQL.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
France France
Just studying everytime !

Comments and Discussions

 
Questionunable to dl please send a correct link Pin
rjheii11-Aug-14 8:05
rjheii11-Aug-14 8:05 
AnswerRe: unable to dl please send a correct link Pin
madagaga9-Nov-16 5:54
madagaga9-Nov-16 5:54 
Questionwhere is your complete code? Pin
Sanjay Monpara17-Apr-14 2:53
Sanjay Monpara17-Apr-14 2:53 
AnswerRe: where is your complete code? Pin
madagaga17-Apr-14 8:04
madagaga17-Apr-14 8:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.