October 3, 2012

NULLIF function


The NULLIF function compares the first parameter (variableB) with second parameter (0). If they are same, it returns a NULL .

Example :

Declare @variableA int 
Declare @variableB int
select @variableA=50, @variableB=0


select @variableA/NULLIF (@variableB,0)

Output:
NULL

No comments:

Post a Comment