Table of ContentsPreviousNext

Database Migration


The Sybase Adaptive Server Anyware IFNULL function returns one of two expressions, depending on whether a specified check expression is NULL or NOT NULL.

Microsoft SQL Server does not support IFNULL. The Microsoft SQL Server searched CASE expression can be used to implement the Sybase Adaptive Server Anyware IFNULL function.

SQLWays changes the Sybase Adaptive Server Anyware IFNULL function to the Microsoft SQL Server searched CASE expression that tests the first expression for NULL.

TABLE 58. Example of the conversion IFNULL with two expressions
Sybase Adaptive Server Anywhere
Microsoft SQL Server
create procedure asa_sp_ifnull (par int,
par2 int)
begin
declare res int;
SET res = IFNULL (par, par2);
end;
create procedure asa_sp_ifnull @par INT,@par2 INT
AS begin
declare @res INT
SET @res = CASE WHEN @par IS NULL THEN @par2 END
end

TABLE 59. Example of the conversion IFNULL with three expressions
Sybase Adaptive Server Anywhere
Microsoft SQL Server
create procedure asa_sp_ifnull (par int,
par2 int, par3 int)
begin
declare res int;
SET res = IFNULL (par, par2, par3);
end;
create procedure asa_sp_ifnull @par INT,@par2 INT, @par3 INT
AS begin
declare @res INT
SET @res = CASE WHEN @par IS NULL THEN @par2 ELSE @par3 END
end


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