Solved

Convert MS SQL .sql files for use with MySQL

Posted on 2010-08-31
4
428 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 32

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Creating and Managing Databases with phpMyAdmin in cPanel.
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…

747 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