0

Have been looking into converting MSSQL to MYSQL. The optioned that seemed best for me was to take a MSSQL.sql and use PhpMyAdmin to import this is.

The following posts and link have been helpful:

How to export SQL Server database to MySQL?

How to convert SQL Server database to MySQL database

http://forums.eukhost.com/f15/how-create-sql-file-mssql-database-created-sql-server-express-12514/#.UO68SHOLJ8s

But when I try to do this it seems to fail with the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

This happens at points of the .sql file like:

USE [Charging]

GO

/****** Object: Table [dbo].[CountryNm] Script Date: 01/10/2013 13:28:42 ******/

Which seem like fundamental parts of a MSSQL.sql file. I have tried removing the USE and GO from the file but then stops at the comments. I have not removed these yet as I am thinking something is perhaps fundamentally wrong with what I am doing?

I have PhpMyAdmin set to Format: SQL, Format-Specific Options: MSSQL and Do not use AUTO_INCREMENT for zero values: Checked.

Many thanks in advance

EDIT: MSSQL Server Management Studio Script Wizard Options:

ANSI Padding: True

Append to File: False

Continue scripting on Error: False

Convert UDDTs to Base Types: False

Generate Script for Dependent objects: False

Include Descriptive Headers: True

Include IF NOT EXISTS: False

Include system constraint names: False

Schema quality object names: True

Script Bindings: False

Script Collation: True

Script Defaults: True

Script Drop : False

Script Extended properties: True

Script for server version: SQL Server 2008

Script Logins: False

Script Object-Level Permissions: False

Script USE DATABASE: False

Script Change Tracking: False

Script Check Constraints: True

Script Date: True

Script data Compression Options: False

Script Foreign Keys: True

Script Full-Text Indexes: False

Script Indexes: False

Script Primary Keys: True

Community
  • 1
  • 1
mflammia
  • 87
  • 2
  • 9

2 Answers2

0

There is no GO keyword, it's a script splitter only for SSMS/OSQL and a few other MS products (customisable from the options).

The USE statement to change database should be fine in MYSQL - see here for a reference. Try swapping GO for a semi-colon to end the statement.

According to the docs, that type of comment is fine for Mysql as well.

Taking both of those into account, try this statement:

USE [Charging];

/* Object: Table [dbo].[CountryNm] Script Date: 01/10/2013 13:28:42 */
Bridge
  • 29,818
  • 9
  • 60
  • 82
  • Thanks for posting. I have removed all the GO keywords, and also the USE as using a semi-colon created a horrible error about a possible finding of a bug? Just for good measure I changed all the comments /**** and ****/ to /* and */. I still get this error: #1064 - 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 '/' at line 1. '/' Should be allowed though right. – mflammia Jan 10 '13 at 15:02
  • @mflammia Is this script a one off? If it's just scripting in a single database, you could delete all of the `USE` statements and comments anyway. Better to eliminate the pointless, make it more likely you'll spot the issue, yes? – Bridge Jan 10 '13 at 15:13
  • True. Have made an edit to my original question above with all the settings for the MSSQL Script wizard. I just re-run it with 'Include Descriptive Headers: False' to get rid of the comments. Now when I import, its runs, but when complete the window just goes completely blank. You still have the PhpMyAdmin window to the left, and the new tables have not appeared? No clues this time. Maybe some of my options in the script wizard of MSSQL could be adjusted but I'm not sure which ones? Thanks – mflammia Jan 10 '13 at 15:57
  • @mflammia I've not used PHPMyAdmin for a while afraid, but I did do a quick google, and came up with [this link](http://www.nichesoftware.co.nz/blog/200907/phpmyadmin-and-white-screen-death) - could this be what you're experiencing? – Bridge Jan 10 '13 at 16:02
  • Managed to get around it in a different way but appreciate your help anyway Bridge. – mflammia Jan 11 '13 at 00:39
0

Well it’s been a particularly painful exercise but I have managed to get the MSSQL database to migrate to MSSQL, which was the ultimate goal. But not going down the route of using PhpMyAdmin which seemed simplest as first glance.

The MSSQL server was isolated so I had to take a backup of the database (.BAK file) and install MSSQL server 2008 express on my local machine. I had a lot of trouble installing Microsoft SQL Management Studio Express separately on my Windows 7 professional PC, but got around this by installing MSSQL server 2008 advanced services. I then restored the backup to that. Not sure if this was needed but I also installed MYSQL ODBC drivers.

I then installed SQL Data Examiner 2012. This allowed me to connect simultaneously to the local MSSQL instance and my remote MYSQL DB. I could then add the tables to the MYSQL DB and run a sync. Doing this fortunately seemed to highlight why I was probably experiencing issues using PhpMyAdmin import, of what most seemed to be tables having more than 16 columns in which MYSQL does not like!

Well it was still a success, in sorts, that I was able to drop a lot of the columns in a few of the tables I exported - hopefully useful to someone else in the same situation.

mflammia
  • 87
  • 2
  • 9