Annotate the stored procedure in SQL Server and create it in mysql.
#! /Usr/bin/perl
Use DBI;
Use Switch;
Use Encode;
Use Encode: CN;
My $ source_name = "sqldb ";
My $ source_user_name = "sa ";
'My $ source_user_psd = "123 ";
My $ db_name = "mysqldb ";
My $ location = "192.168.0.208 ";
My $ port = "3306 ";
My $ db_user = "zoe ";
My $ db_pass = "123 ";
My $ dbh = DBI-> connect ("dbi: ODBC: $ source_name", $ source_user_name, $ source_user_psd );
# Getting all user tables
My $ something = $ dbh-> prepare ("select name from sys. objects where type = 'P '");
$ Something-> execute ();
My $ n = 0;
My $ OK = 0;
My $ sort_column = "";
While (@ data = $ something-> fetchrow_array ())
{
# Print $ data [0];
Print 'query table '. $ data [0]. "Stored Procedure \ n ";
My $ SQL _create = "EXEC Sp_HelpText '$ data [0]'";
My $ dbh_mssql = DBI-> connect ("dbi: ODBC: $ source_name", $ source_user_name, $ source_user_psd, {RaiseError => 1 });
$ Dbh_mssql-> {LongTruncOk} = 1;
$ Dbh_mssql-& gt; {LongReadLen} = 1048576;
My $ sth_select = $ dbh_mssql-> prepare ($ SQL _create );
$ Sth_select-> execute () or die 'cannot execute: '. $ sth_select-> errstr ();
My $ select_col;
My $ select_data;
While ($ select_data = $ sth_select-> fetchrow_array ())
{
$ Select_col. = $ select_data;
}
Do_ SQL ($ data [0], $ select_col );
}
$ Something-> finish;
$ Dbh-> disconnect;
Print 'stored procedure creation of all Table'. "\ n ";
Sub do_ SQL
{
Print 'start to create'. $ _ [0]. 'table Stored Procedure'. "\ n ";
My $ SQL =$ _ [1];
Open (FILE, "》createtableallproduce.txt ");
Syswrite (FILE, "$ n \ n ");
Syswrite (FILE, "$ data [0] \ n ");
Syswrite (FILE, "$ SQL \ n ");
Close (FILE );
$ SQL = ~ S/\ */------ annotation starts --------/g;
$ SQL = ~ S/\ * \ // ------ end the annotation --------/g;
$ SQL = 'create processure '. $ _ [0]. '()'. "\ n ". 'begin '. "\ n ". '/*'. $ SQL. '*/'. "\ n ". 'End ;';
My $ data_base = "DBI: mysql: $ db_name: $ location: $ port ";
My $ dbh3 = DBI-> connect ($ data_base, $ db_user, $ db_pass );
$ Dbh3-> do ("SET character_set_client = 'utf8 '");
$ Dbh3-> do ("SET character_set_connection = 'utf8 '");
My $ data_str = encode ("UTF-8", decode ("gbk", $ SQL ));
My $ something = $ dbh3-> prepare ($ SQL );
Open (FILE, "Export myproduce.txt ");
Syswrite (FILE, "$ n \ n ");
Syswrite (FILE, "$ data [0] \ n ");
Syswrite (FILE, "$ SQL \ n ");
Close (FILE );
$ Something-> execute () or die "$ data_str ---- ERROR ::$ data_str ::$ dbh3-> errstr ";
$ Dbh3-> disconnect;
Print 'create'. $ _ [0]. 'END of the table Stored Procedure '. "\ n ";
}