Total Pageviews

NULLIF ()

NULLIF function returns NULL, if both passed expression are same.
If both expressions are not same then this function returns first expression as an result.

SELECT NULLIF(1,1) ------> NULL
SELECT NULLIF (1,2) ------> 1

facebook page


ISNULL in SQL Server

ISNULL() accepts two arguments. If first argument (or expression) is 'NULL' then it returns second argument as output else it returns first argument as an output.

For example:-

SELECT ISNULL(1, 5) --> 1 will be output
SELECT ISNULL (NULL, 5) --> 5 will be output
SELECT ISNULL (NULL, NULL) --> NULL will be output
SELECT ISNULL (1, NULL) --> 1 will be output