Thursday, June 24, 2010

Differences between COALESCE and NULLIF


COALESCE
NULLIF
It Accepts N Parameters, It returns first Not Null Values

For Example:-
select coalesce(NULL,2,NULL,3)
Output :- 2
It Accepts 2 Parameters, if both are not equal then it will return first value.

For Example:-
SELECT NULLIF(1,2)
Output :- 1
First argument can be NULL, but both argument can not NULL value
First argument can not be NULL input
If Both argument are equal, then it will return first value.

For Example:-
SELECT NULLIF(2,2)
Output :- 2
If Both argument are equal, then it will return NULL value.

For Example:-
SELECT NULLIF(2,2)
Output :- NULL

2 comments:

  1. To learn .net, C#, Java, Silverlight, Visual Basic, Asp .net with advanced concepts, you can visit http://advanceddotnettutorial.blogspot.com

    ReplyDelete