Solved

Convert MS SQL .sql files for use with MySQL

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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…

679 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