• BrainDonor (4/13/2010)


    It could have possibly have been phrased slightly better ("The fixed value NULL", or something like that), but it is correct. NULL does not equal NULL. Try comparing two NULL values in SQL - they will never be equal. A NULL field is actually unknown, so anything involving a NULL has an unknown value. Endless hours of fun for the unwary.

    The sentence "NULL does not equal NULL" is correct, when you have ANSI_NULLs on...

    On the other hand, the statement "Try comparing two NULL values in SQL - they will never be equal" is just wrong. Try this:

    SET ANSI_NULLS OFF

    IF Null = Null

    PRINT 'Oops, Null equals Null today!'

    The Phrase "A NULL field is actually unknown, so anything involving a NULL has an unknown value" is reasonable. From that to "[the question] is correct" is a long stretch;

    The question did not ask "What does Null Equal" (and even then "UNKNOWN" would not have been an accurate answer!) - it's simply a terrible terrible question, there's nothing "correct" about it.

    (Edit: had my booleans wrong, further confusing things)

    http://poorsql.com for T-SQL formatting: free as in speech, free as in beer, free to run in SSMS or on your version control server - free however you want it.