• oscar.leeper (9/1/2010)


    On both my 2k8 and 2k5 installations, I only got the OR behavior to match the article. Is there a setting I'm missing?

    No, you are making a logic error. Your test does not distinguish between Unknown (sorry for being pedantic, but the third value in three-valued logic is NOT NULL, but Unknown). According tho the truth tables, the AND test should return False. And it does, but you'd get the same output if it did return Unknown.

    Try it with this code:

    if(1=1 or 1=null)

    print 'test passed'

    else

    if not(1=1 or 1=null)

    print 'test didn''t pass'

    else

    print 'test result unknown'

    if(1=0 and 1=null)

    print 'test passed'

    if not(1=0 and 1=null)

    print 'test didn''t pass'

    else

    print 'test result unknown'


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/