I am attempting to update rows in a table - some of the parameters will be null and I need to update the row field to reflect that.
I assumed that (simplified SQL to demonstrate)
DECLARE @Bid DECIMAL(8,7)
DECLARE @Result INT
SELECT @Result = 0
SELECT @Result =
CASE @Bid
WHEN NULL THEN 1
ELSE 2
END
SELECT @Result
would give me a value of 1 if it follows the same logic as when testing with an INT (I am using the IS to compare rather than equals)
DECLARE @Bid DECIMAL(8,7)
DECLARE @Result INT
SELECT @Result = 0
SELECT @Bid = 4
SELECT @Result =
CASE @Bid
WHEN 4 THEN 1
ELSE 2
END
SELECT @Result
However, it doesn't, so I have to rewrite the SQL as
DECLARE @Bid DECIMAL(8,7)
DECLARE @Result INT
SELECT @Result = 0
SELECT @Result =
CASE
WHEN @Bid IS NULL THEN 1
ELSE 2
END
SELECT @Result
which works.