checksum_agg()

  • declare @t1 table (i int)

    declare @t2 table (j int)

    insert @t1 values (1)

    insert @t1 values (2)

    insert @t1 values (3)

    insert @t1 values (4)

    insert @t1 values (5)

    insert @t2 values (1)

    insert @t2 values (3)

    insert @t2 values (5)

    insert @t2 values (7)

    insert @t2 values (8)

    insert @t2 values (9)

    select * from @t1 full join @t2 on i=j

    select checksum_agg(i) from @t1

    select checksum_agg(j) from @t2

    Why the heck is the checksum same?

  • How about a simple because. I ran your code as is and both checksum_agg returned the same value, 1. I then took the last value out of the second table, and viola different results. That tells me the that the calculation of the checksum for the two original sets of values just happened to return the same value.

    Nothing says that you will get unique results.

  • >Nothing says that you will get unique results.

    Exactly. Or more precise 'no one'. So, what's checksum_agg() good for (in real life s/w world)?

  • If you read BOL it says it can be used to detect changes of data in a column of data. You noticed that the value changed when a row was removed. You have to remember that it isn't fool-proof. It is possible that the changes made could still result in the same value being returned.

    Beyond that, I really couldn't give you a real-world example where I might use it.

  • If I wanted to know that I'd ask my 3 year old daughter...

  • Ah, sarcasm, that I get.

    You know, if I had an answer I'd have given it to you. Can I think of a reason I'd use it, no. Does that mean there isn't one, no.

    Thank you.

  • sense of humor, please

  • deepforest (1/29/2009)


    sense of humor, please

    yes, have that I do. 😛

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

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