11

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 ?

0

4 Answers 4

7

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

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

4 Comments

The editor does not convert any more - you can paste MySQL etc in but nothing happens when you press convert.
It worked to me. Perhaps you didn't change the destination type
This thing has many errors! Whenever I convert a mysql database, there'are many errors
not working now
2

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.

2 Comments

I think he just wanted to convert sql script and did not know the mysql's connection details like host and acct (guess like me now am needing to fetch wordpress blogs
Yes. If you look at that link, you find the header 'Using Data Loading'. The export file the OP allready has is the one you need the connection details for, as described in the part 'Generating mysqldump Data Extract Scripts'. So you can skip that step, and go from there.
0

There are a few ways to test whether a table exists in SQL. Here is one approach.

if object_id('<table>','U') is not null  drop <table>

So you would need to convert all of the

DROP TABLE IF EXISTS `kladr`;

to that syntax. Note that there are other approaches to see if a table exists as well.

Also, MS-SQL doesn't use the ` (backtick) character, so you would need to get rid of all of them. However, some of the field/table names currently surrounded by backticks might be reserved words, in which case, you need to delimit those fields/tables with [fld_name] with brackets.

You might also run into some differences in the create table syntax, also the basic syntax is similar. The examples above would work in MS-SQL...

You can do it with script editing, but I would strongly suggest using the link suggested by Nanne above. Good luck

Comments

0

You could (re)create the MySQL database from the MySQL scripts you received and use a database conversion tool. I have used FullConvert in the past and works excellent. Supports many databases and is very fast!

1 Comment

Microsoft also has a free suite of conversion tools for converting to SQL Server. There is one for MySQL learn.microsoft.com/en-us/sql/ssma/mysql/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.