Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert mySql SQL script to MS SQL one?

I have to migrate customer MySql database schema/data to MS SQL SERVER 2008. Finally I've received 70 Mb SQL file with mySQL dialect that is incompatible with MSSQL.

DROP TABLE IF EXISTS `kladr`;
CREATE TABLE `kladr` (
  `id` int(11) NOT NULL DEFAULT '0',
  `idp` int(11) DEFAULT NULL,
...

It took a week of negotiations to receive such a file so I'm afraid to ask mySQL administrators to send me MS SQL SERVER compatible sql. Is there a way to convert mySQL dialect to MSSQL SERVER dialect automatically ?

like image 979
Andrew Florko Avatar asked Oct 19 '11 11:10

Andrew Florko


2 Answers

SQLines provides tools and services to help you transfer data, convert database schema (DDL), views, stored procedures and functions, triggers, queries, embedded SQL statements and SQL scripts from MySQL to Microsoft SQL Server.

http://www.sqlines.com/online

like image 113
Jerold Joel Avatar answered Nov 04 '22 13:11

Jerold Joel


The easiest method would be to obtain a converter. There are multiple options available, but It might be difficult to find a good one: a lot of spammy options are available, all costing money ofcourse.

Microsoft has a manual online for migration: http://technet.microsoft.com/en-us/library/cc966396.aspx

You'll be needing some mysql tools and some mssql tools, stated on above link.

Adding a short exerpt:
If you check out the part called 'Using Data Loading'. The export file you allready have is probably fine, so you can go and skip 'Generating mysqldump Data Extract Scripts'.

Now the part you need:

Using the extracted scripts with SQL Query Analyzer
Generated scripts can now be used to create database objects and insert data. The preferred method to construct a database schema from MySQL scripts is to use the SQL Query Analyzer tool that is included with SQL Server 2000.
You can run SQL Query Analyzer directly from the Start menu, or from inside SQL Server Enterprise Manager. You can also run SQL Query Analyzer from the command prompt by executing the isqlw utility.
In order for the script to correctly execute there is some additional work required, which involves certain changes with the SQL dialect. Also, remember to walk through the SQL script and change the data types to SQL Server compatible types. The diagram below shows an imported script from mysqldump, it is important to note that the dump is an ASCII script file.

like image 26
Nanne Avatar answered Nov 04 '22 13:11

Nanne