NULLIF :
-
It is a Function
-
Returns a NULL value if the two specified expressions are equal
-
Returns first expression, If the specified expressions are NOT equal
/*Both expressions(@A and @B) are Equal*/
Declare @A Int, @B Int
Select @A = 100, @B = 100
Select NULLIF(@B, @A) [Result]
Result
NULL
/*Both expressions(@A and @B) are NOT Equal*/
Declare @A Int, @B Int
Select @A = 100, @B = 101
Select NULLIF(@B, @A) [Result]
Result
101
ISNULL :
-
It is a Function
-
Returns second Expression, If the first one is NULL
-
Returns first expression, If the first one is NOT NULL
Declare @A Int
Select @A = 100
Select ISNULL(@A,0) [Result]
Result
100