Table of ContentsPreviousNext

Database Migration


Conversion of Variable Declarations from Microsoft SQL Server to MySQL

The DECLARE statement is used to declare variables in Microsoft SQL Server and allows declaring variables with different data types. The MySQL DECLARE statement allows declaring a list of variables with one data type only, which is specified at the end of the variable list.

SQLWays converts the Microsoft SQL Server DECLARE statement with a list of variables to a standalone DECLARE statement for each variable in MySQL.

Microsoft SQL Sever local variable name (@var) is changed to MySQL local variable name with the only difference that symbol "@" (which in Microsoft SQL Server designates local variable) is changed to MySQL "v_". The reason of this change is that in MySQL symbol "@" is used to designate user variable. User variable means that variable is working during the whole connection to the database. In this case we must use local variable, which works only within a procedure body. .

TABLE 17. Example of Conversion of variable declarations from Microsoft SQL Server to MySQL
Microsoft SQL Server
MySQL

Create procedure mssql_declare_mysql
As
Begin
DECLARE @x INTEGER, @y CHAR
end

Create procedure mssql_declare_mysql( )
Begin
DECLARE v_x INT;
DECLARE v_y CHAR;
end ;


Ispirer Systems
http://www.ispirer.com
ispirer@ispirer.com
Table of ContentsPreviousNext