ISNULL and NULLIF SQL SERVER

Опубликовано: 02 Ноябрь 2024
на канале: Vikash DBA (RDMS tutorial)-SQL GUIDE
985
9

Difference between ISNULL and NULLIF SQL SERVER?
please watch complete so you can understand the difference

ISNULL (Transact-SQL)
ISNULL ( check_expression , replacement_value )
--first argument is NULL so function return the second argument
SELECT
ISNULL(NULL,1)

--character string example
--first argument is not null so it returned first argument only
SELECT
ISNULL('DBA', 'SQL')


NULLIF
--For example,
returns NULL for the first column (3 and 3)
because the two input values are the same

SELECT NULLIF(3,3)
go
select NULLIF(6,7) -- returns the first value (6)
--because the two input values are different.

SELECT NULLIF('DBA', 'DBA')
SELECT NULLIF('SQL', 'DBA')