Difference between nullif and isnull

1.2K    Asked by LiamDyer in SQL Server , Asked on Nov 21, 2019
Answered by Rachit Gupta

Isnull is a function which will check if the first value is null then return the second value, if first value is not null then it will return the first value only

declare @name varchar(30),@replace_name varchar(30)

set @name=null

set @replace_name='Replaced_ALEX'

select isnull (@name, @replace_name)


set @name='Alex'

set @replace_name='Replaced_ALEX'

select isnull (@name, @replace_name)


Nullif is a function which will check if the first value parameter is equal to the second parameter then it will return a null value.

select nullif(1,1)



Your Answer

Interviews

Parent Categories