August 13, 2021 at 12:00 am
Comments posted to this topic are about the item Zero or Hero?
August 13, 2021 at 12:11 pm
What is more interesting is that
IF (1 <> 1)
BEGIN
DECLARE @NumOfHolidays INT;
SET @NumOfHolidays = 0;
END
SELECT @NumOfHolidays;
returns null, not an error
August 13, 2021 at 1:49 pm
Right, very interesting!
--------------------------------------
;-)“Everything has beauty, but not everyone sees it.” ― Confucius
August 13, 2021 at 3:25 pm
Good point Larry. If I add an ELSE to Larry's query and try to define @NumOfHolidys with a different data type I get an error that the variable name has already been declared and must be unique within a batch. A good example of why you should probably, for clarity, place your declare statements prior to the code that will reference the variables.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply