• i think you just misinterpreted the answers. when he says "i is null", he means that the result of "If @i is null" evaluates to true, and so he's just printing "i is null".

    to break down the question,

    "Declare @i int"

    @i is declared as an int, and not given an initial value. as such, when initialized, it defaults to a value of NULL.

    "--Test #1

    If @i is null

    Print 'i is null'

    Else

    Print 'i is not null'"

    test 1 is checking to see if the value of @i is null. in this case, since it was defaulted to null, test 1 evaluates to true. on the true case, it prints "i is null", so that's what is displayed.

    "--Test #2

    if @i = 0

    Print 'i = 0'

    Else

    Print 'i 0'"

    test 2 is checking to see if the value of @i is 0. since @i is null, it fails this check, as @i = 0 evaluates to "UNKNOWN" due to @i being null. so, the else case is used.

    "--Test #3

    If not @i = 0

    Print 'i 0'

    Else

    Print 'i = 0'"

    test 3 is checking to see if the value of @i is not 0. again, since @i evaluates to null, and null is not equal to zero, the statement returns false. and not false is true, so the first case is used, and "i 0" is printed.

    ANSI_NULLS causes the script to return UNKNOWN when comparing any result against NULL.

    as for your question Sanjay, i'd suggest that you always use ANSI_NULLS on, so that you can avoid running into any problems when doing null comparisons.