Zero or Hero?

  • Comments posted to this topic are about the item Zero or Hero?

  • What is more interesting is that

    IF (1 <> 1)

    BEGIN

    DECLARE @NumOfHolidays INT;

    SET @NumOfHolidays = 0;

    END

    SELECT @NumOfHolidays;

    returns null, not an error

     

  • Right, very interesting!

    --------------------------------------
    ;-)“Everything has beauty, but not everyone sees it.” ― Confucius

  • 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