Solved

Convert MS SQL .sql files for use with MySQL

Posted on 2010-08-31
4
434 Views
Last Modified: 2012-05-10
I'm using MySQL 5, I have several .sql files for building tables that were generated by MS SQL, is there any easy way to convert them so that I can use them with MySQL?
0
Comment
Question by:Bang-O-Matic
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
bogdan_iuly earned 250 total points
ID: 33568938
Hello,

If you don't have many tables, you can do the following (in Notepad)::
- replace bit with tinyint or what other type of field you want to use
- replace [ with empty string
- replace ] with empty string
- replace dbo. with empty string
- replace ON [PRIMARY] with empty string

Now:
- manually  delete the code after the constraint, which is in my case:
WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

I hope this helps a little.

Thank you

What you start up with:



CREATE TABLE [dbo].[TEST](

	[TESTFLD] [varchar](255) NOT NULL,

	[TESTBIT] [bit] NOT NULL,

 CONSTRAINT [PK_TEST] PRIMARY KEY CLUSTERED 

(

	[TESTFLD] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY]















What you end up with:



CREATE TABLE TEST(

	TESTFLD varchar(255) NOT NULL,

	TESTBIT tinyint NOT NULL,

 CONSTRAINT PK_TEST PRIMARY KEY CLUSTERED 

(

	TESTFLD ASC

)

)

Open in new window

0
 

Author Comment

by:Bang-O-Matic
ID: 33569402
Thanks for the help, I have several large tables to build, I am more looking for a possible software solution? maybe something that will re-write these files to make them MySQL compliant.
0
 
LVL 33

Assisted Solution

by:ste5an
ste5an earned 250 total points
ID: 33576602
Build your database on a SQL Server (Express) instance and use MSSQL2MYSQL:

  http://dev.mysql.com/tech-resources/articles/migrating-from-microsoft.html

Or use the MySQL Migration Toolkit:

  http://dev.mysql.com/downloads/gui-tools/5.0.html


mfG
--> stefan <--
0
 

Author Closing Comment

by:Bang-O-Matic
ID: 33577801
Thanks!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now