20

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?
3
  • You are trying to migrate a database or data? There is a tool that you don't need to install, just execute and it does the rest. Commented Nov 20, 2013 at 22:27
  • @JorgeCampos It's database and a little bit data into. Commented Nov 20, 2013 at 22:29
  • I had to migrate MS SQL to MySQL and wrote Q̛&A about that: stackoverflow.com/questions/38942424/… not a straightforward solution and requires installing of the tools, but may help someone Commented Aug 14, 2016 at 13:15

3 Answers 3

5

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).

Sign up to request clarification or add additional context in comments.

1 Comment

This answer doesn't actually provide an answer, and also contradicts itself ("You don't just convert.." -> You need to convert from AUTO_INCREMENT to IDENTITY).
2

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

Comments

0

I used this online tools and its absolutely fine. http://www.sqlines.com/online

2 Comments

I tried this one. The converted script is good for creating new tables. For insertion, it fails.
The suggested sqlines does a terrible job of converting scripts. For example, my simple MSSQL script was: <code>if not exists (select * from INFORMATION_SCHEMA.COLUMNS where table_name='Orgs') begin create table Orgs ( OrgId varchar(50), Name varchar(250), Add1 varchar(250), Add2 varchar(250), City varchar(50), Pin varchar(15), TelNos varchar(250), Email varchar(500) ) end go... </code> When I converted to Mysql, sqlines just removed the "go" and added semicolons, but did no real conversion. It left INFORMATION_SCHEMA.COLUMNS as it is, which fails in mysql.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.