Returning a NULL Value When Two Expressions Are Equal: Otherwise Return the First Expression : NULLIF « Data Convert Functions « SQL Server / T-SQL Tutorial






5> DECLARE @Value1 int
6> DECLARE @Value2 int
7> SET @Value1 = 55
8> SET @Value2 = 955
9> SELECT NULLIF(@Value1, @Value2)
10> GO

-----------
         55

(1 rows affected)
1>
2>
3> DECLARE @Value1 int
4> DECLARE @Value2 int
5> SET @Value1 = 55
6> SET @Value2 = 55
7> SELECT NULLIF(@Value1, @Value2)
8> GO

-----------
       NULL

(1 rows affected)
1>








13.6.NULLIF
13.6.1.Returning a NULL Value When Two Expressions Are Equal: Otherwise Return the First Expression