I have a database schema from MySQL which I want to import to SQL SERVER, I have tried dumping from MySQL with compatibility for SQL Server, but with no success. Tried dumping as Excel still no dice. Does anyone know another way to import this database with no records from MySQL to SQL SERVER 2012? Thanks for your time.

  • What problems did you encounter with the dump (sqlserver compatibility)? How does the dump file look like once opened with an editor? – KookieMonster Apr 8 '13 at 10:48
  • Within sql server when I try to run the file as a query, troggers and all, I get several syntax errors. From the CREATE TABLE DROP IF EXISTS commands to the int data type declarations. After dumping the file to .sql I could just open it with sql server and that is how I tried to run the query. – kabuto178 Apr 8 '13 at 11:47

I recently had to do essentially the same thing, except that I wanted to migrate MySQL tables and data to SQL Server. I tried:

  • using phpMyAdmin to Export the table definitions with "MSSQL" compatibility: The resulting SQL script would not execute in SQL Server Management Studio (SSMS) due to syntax errors.

  • using HeidiSQL to export the MySQL database directly to SQL Server: HeidiSQL also generated SQL statements that SQL Server would not accept.

  • using MySQL Workbench: I could not find a way to migrate a database from MySQL to SQL Server.

  • using MySQL ODBC and the SQL Server Import and Export Wizard: The wizard crashed (i.e., the Windows "[Application name] has stopped working..." error) when trying to access the MySQL database.

The only method that didn't fail outright was to pull the tables from MySQL into a Microsoft Access .mdb file (!) via MySQL ODBC, then import that into SQL Server.

However, even that was an incomplete solution because the transfer from MySQL to Access omitted all of the primary keys, indexes, and AUTO_INCREMENT attributes. Still, it did transfer the tables and data, which was my main objective. I just had to write some T-SQL to re-create the indexes and whatnot.

Since you don't need to transfer any data you might want to consider just hacking the mysqldump SQL code (good old Find & Replace...) to the point where SQL Server will execute it.

  • Thanks for the advice, this has been giving me a bit of trouble as it seems we tried similar solutions. – kabuto178 Apr 8 '13 at 12:15

I tried Microsoft SQL Server Migration Assistant v6.0 for MySQL which did most of the work for converting the schema and migrating the data from MySQL to SQL Server.

  • It worked flawlessly for me, when all other options has failed. Thanks for this tip! – Fernando Vieira Jul 31 '19 at 3:23

The easiest way could be:

  1. Export your MySql database as a csv file with the name of the columns as headers.
  2. Create an empty database in SQL (I did it on SQL Server 2012)
  3. Import the csv file into the empty database. You might need an ODBC component depending on which version of SQL and Framework you are working on (Microsoft.ACE.OLEDB.12.0). I noticed The Keys were missing, but I just added them manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.