Quick note on NULLS: NULL means “Unknown Value”, not “0”. So adding a value to NULL results in NULL:

1 + NULL = NULL

Because NULL means “I Don’t Know”, adding two NULLS together does not equate to the same value; it’s still two indeterminate values.

NULL + NULL != NULL

You can work around this in T-SQL by using COALESCE.


declare @i VARCHAR(8) = NULL
declare @j VARCHAR(8) = NULL
SELECT @i

SELECT @i + 'bob'

SELECT COALESCE (@i, 'bob')

if @i = @j
select 'yes'
else
select 'no'