mysql run sql files_MSSQL转MYSQL工具 tsql2mysql.exe 使用说明

tsql2mysql.exe下载地址

国外的哥们用C++做的一个基于命令行的批量转换存储过程的工具,从MSSQL转化成MYSQL。

操作步骤如下:

1:备份出SQL SERVER存储过程,使用ANSI编码,UTF8的支持。一个文件内可以有一个或者多个存储过程

2:

D:\tsql2mysql1.1>tsql2mysql c:\mysql2.txt

3:导入到MYSQL数据库。

127.0.0.1~root@localhost~test>source c:\mysql2.txt

下面贴出英文操作说明:

=====================================================================

Tsql2mysql is a tool designed to help with conversion of stored procedures from Microsoft T-SQL to MySQL, ANSI-based, syntax. It does not do a complete conversion, in most cases you will probably have to make manual changes too.

How to run

The tool is command line based, reads from standard input and writes to standard ouput. It works with script files and does not connect to the database. To use it, take the following steps:

- dump your procedures from SQL Server database to script files. Use ANSI format, UTF is not supported. You can have one or several procedures in every file

- run the tool with the following command: tsql2mysql [outfile]

- load the result into MySQL tool, for example the Query Browser, run it, correct errors, review out-commented code

What it does

Tsql2mysql does the following:

1) converts CREATE PROCEDURE/FUNCTION syntax

2) adds semi-colon at the end of statements

3) converts IF and WHILE statements to MySQL syntax

4) sorts the code in the correct order, with declarations at the top and instructions after that

5) removes @, [ and ] from identifiers

6) converts comments to MySQL syntax (a space in the 3rd position for -- comments)

7) adds a CONTINUE HANDLER FOR NOT FOUND if the procedure contains cursors

8) comments out GOTO and labels (you will have to restructure this yourself, since there is no GOTO in MySQL stored procedures)

9) converts some data types (nvarchar, identity, smalldatetime, money, smallmoney)

10)Converts function with a direct MySQL correspondence (getdate, getutcdate, len, replicate)

11)Converts SQL Server temporary tables (the INTO #temptable) to MySQL CREATE TEMPORARY TABLE

What it does not do

The tool does not convert GOTO:s and labels. There are no GOTO:s in MySQL stored procedures. You will have to solve this by hand. The tool comments them out by adding a comment before the statement:

-- Can not be converted: GOTO wherever

The tool does not add MySQL/ANSI error handlers to the code. It the old procedures does error handling the Microsoft way, this should probably be done.

Feedback and bug reports

Your comments and suggestions are welcome. Be sure to include the original procedure/function code if you submit a bug report or request.

Changes in version 1.1

Version 1.1 includes convertion of SQL Server temporary table syntax. It also handlas CASE statements better, supports very large SQL statements and features improved pretty-printing of the code.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值