CHECKSUM() and NULL

  • Comments posted to this topic are about the item CHECKSUM() and NULL

    God is real, unless declared integer.

  • Good question many thanks.

    ...

  • Nice one, thanks Thomas

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Very nice question about a function I use with some frequency.  Thanks.

  • Well done !!

  • Given the behavior of nulls elsewhere, I surely expected this function to also return null. I'm guessing that maybe that would invalidate the practicality of the checksum function, so an interesting design choice on that one!

  • Nice question.  

    It's rather a pity that checksum doesn't take account of the type of a NULL, but that will only very rarely be a pain. 

    The documentation is awful, though:  "CHECKSUM applied over any two lists of expressions returns the same value if the corresponding elements of the two lists have the same type and are equal when compared using the equals (=) operator. For this definition, null values of a specified type are considered to compare as equal" is likely to mislead people into believeing that NULLs of different type don't make the same contribution to a checksum, and that values that compare as equal don't have the same checksum if they have different types.  This mostly isn't a problem, because comparing checksums of things whose types don't match is a bit crazy anyway.   But that text on teh BOL page really looks silly when a string containing 3 characters existsing as things with types char(26), varchar(107), and varchar(max)  will have the same checksum  or each of those types, regardless of whether ANSI_PADDING is ON or OFF.   That really does make the documentation look as is it is designed to mislead.

    Tom

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply