全部博文(99)
分类: Mysql/postgreSQL
2010-08-24 00:22:34
|
3:导入到MYSQL数据库。
|
下面贴出英文操作说明:
=====================================================================
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.
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
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
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.
Your comments and suggestions are welcome. Be sure to include the original procedure/function code if you submit a bug report or request.
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.