SQL SERVER 2005 – What is NULLIF ?
Returns a null value.
NULLIF returns the first expression if the two expressions are not equal. If the expressions are equal, NULLIF returns a null value of the type of the first expression.
Create Table #temp
(
id int,
FName varchar(20),
Address varchar(100)
)
Insert into #temp values(1,‘Rana’,‘Code project address’)
go
Insert into #temp values(1,‘Roger’,‘US Florida’)
go
Insert into #temp values(1,‘Toni’,‘US’)
SELECT id, FName, Address,
NULLIF(Address,‘US Florida’)AS ‘Null if Equal’
FROM #temp
NULLIF is equivalent to CASE function
SELECT id, FName, Address,
CASE WHEN Address =‘US Florida’ THEN NULL ELSE Address END AS ‘Null if Equal’
FROM #temp






what do you mean by null value of the type of the first expression. Do we have different Nulls for integer and character types ?