MSSQL to MySQL Guide to Migration Part - 1

UPDATED: 26 January 2014
Database Migration is very important process of product based application. You may find bunch of software to migrate table structure from MSSQL to MySQL. There are very few software (Not any with full conversation) available to migrate Stored Procedure, Functions and Views.

I did this before so better not to waste your precious time to search for tools. You have to manually convert all Stored Procedure, Functions and Views. I came up with some basic rules that may help you to convert all of above.


1. "DECLARE" a variable in MSSQL and MySQL. 
You may think is it really matter? Yes, It is. MSSQL and MySQL follows different rules for declaring variables.

  • MSSQL: Variable name starts with '@'.
  • MySQL: You can't use '@'.
  • -------------------------------------------------------------------------
  • MSSQL: You can declare variable anywhere in Stored Procedure, Functions.
  • MySQL: You have to declare variable at the starting of Stored Procedure, Functions.

2. "ISNULL" in MSSQL is similar to "IFNULL" in MySQL.

3. Using "IF".
-- MSSQL
IF (condition)
BEGIN
     ......
END
ELSE IF (condition)
BEGIN
     ......
END
ELSE
BEGIN
     ......
END
--------------------------------
-- MySQL
IF (condition) THEN
     ......
ELSEIF (condition) THEN
     ......
ELSE
     ......
END IF;
4. "LEN" in MSSQL is similar to "LENGTH" in MySQL

5. Function in MSSQL and MySQL
You may wonder that MSSQL can return table from function but unfortunately MySQL can't. If you have function in MSSQL which returns table, then you've to convert that function in stored procedure in order to get table as return value. There ain't other option in MySQL. MySQL function can only return single value.

6. MySQL: How to select data from Stored Procedure in to Stored Procedure
Article posted at http://www.javaquery.com/2014/01/mysql-how-to-select-data-from-stored.html

7. Temporary tables in MySQL.

Its not written here because its very important part of conversion. We need to discuss it with proper examples. I'll write separate articles for it.

MSSQL to MySQL Guide to Migration Part - 2 is published at http://www.javaquery.com/2014/02/mssql-to-mysql-guide-to-migration-part-2.html

0 comments :