Solved

Convert MS SQL .sql files for use with MySQL

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find results from sql within a time span 11 46
SQL replication over high latency link 10 60
MySQL Backup Strategy 15 44
Generate Unique ID in VB.NET 21 62
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Read about achieving the basic levels of HRIS security in the workplace.
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…

837 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