Why does the following expression in SQL Server return -9223372036854775808
and not 123
?
I am calling this from a stored proc where I can't pass null parameters
declare @t bigint;
set @t = -9223372036854775808; --min value for bigint / long
select ISNULL(@t, 123)
Because:
IF @t IS NOT NULL
PRINT @t
ELSE
PRINT 123
Being negative doesn't mean the value is NULL. NULL is the lack of any value at all.
Because @t is not null.
What made you think that the most negative value for a bigint would be interpreted as null?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With