Chinaunix首页 | 论坛 | 博客
  • 博客访问: 477683
  • 博文数量: 99
  • 博客积分: 3621
  • 博客等级: 中校
  • 技术积分: 1089
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-22 16:29
文章存档

2012年(21)

2011年(28)

2010年(50)

分类: Mysql/postgreSQL

2010-08-24 00:22:34

tsql2mysql.exe下载地址
 
国外的哥们用C++做的一个基于命令行的批量转换存储过程的工具,从MSSQL转化成MYSQL。
 
操作步骤如下:
1:备份出SQL SERVER存储过程,使用ANSI编码,UTF8的支持。一个文件内可以有一个或者多个存储过程
2:

D:\tsql2mysql1.1>tsql2mysql <c:\tsql.txt > 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 <[infile] >[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.


阅读(1738) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~