• This next table summarizes the effect of NULLs in AND expressions:

    AND True False NULL

    True True False NULL

    False False False False

    NULL NULL False NULL

    This second table summarizes the effect of NULLs in OR expressions:

    OR True False NULL

    True True True True

    False True False NULL

    NULL True NULL NULL

    I tested both of these truth tables for the underlined conditions:

    false AND null

    and

    true OR null

    because I wasn't sure about the behavior here. The programmer in me said short circuiting might work, while the ternary logician in me misremembered a NULL result in both of those conditions. On both my 2k8 and 2k5 installations, I only got the OR behavior to match the article. Is there a setting I'm missing? I tried this with ansi_nulls both off and on with the same result.

    using this SQL:

    if(1=1 or 1=null)

    print 'test passed'

    else

    print 'test didn''t pass'

    if(1=0 and 1=null)

    print 'test passed'

    else

    print 'test didn''t pass'

    My output is:

    test passed

    test didn't pass