Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert mssql script to mysql

I tried to convert script from MS SQL Server to MySql.

I couldn't find any convenience approach to do this conversion.

I tried this MS SQL Server to MySQL Conversion online converter but it has a lot of mistakes at syntax.

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTITY(1,1) NOT NULL,
`address` varchar(255) NOT NULL,
`date_added` datetime N' at line 2

Here is content of the file that I need to convert pastebin - script

  • Does any better way to make this conversion but without installing special tool exist?
like image 905
catch23 Avatar asked Nov 20 '13 22:11

catch23


2 Answers

You don't just "convert" TSQL to SQL code for MySQL. You need to know the different datatypes, column constraints, etc. You hit the first of many roadblocks: MySQL uses AUTO_INCREMENT instead of SQL Server's IDENTITY field constraint.

EDIT: There are utilities, but you should still understand what the changes are, as they'll affect many things (including performance and future development against the DB). Duplicate of several other posts (dead link removed).

like image 179
tommy_o Avatar answered Oct 19 '22 04:10

tommy_o


The converter at http://burrist.com/mstomy.php runs a set of regexps to do the conversion – the regexps list isn’t exhaustive and can be modified as required. I’ve added a couple of extra lines to the standard regexps and it now creates a working version of your script up to the point you start inserting data (it only does tha structure not the data). Hope this is of interest.

Cheers sql-hub.com

like image 42
Alan Hickman Avatar answered Oct 19 '22 05:10

Alan Hickman