Mega Code Archive

 
Categories / MSSQL Tutorial / Data Convert Functions
 

Returning a NULL Value When Two Expressions Are Equal

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>