views:

291

answers:

1

I am trying to solve a unique problem. Thanks for any help with this.

Is there an easy way to generate some kind of a hash code for a record based on several of its field values?

I thought about just creating a view with an extra column that concatenates all of the values that I want to check, but I'm checking to see if there is a better way.

I am trying to identify records based on their values, because I need to group parent records by the uniqueness of these child records, if that makes any sense.

Thanks again for any advice.

+2  A: 
SELECT
    HASHBYTES('MD5', CAST(col1 AS VARBINARY(MAX)) + 
        CAST(col2 AS VARBINARY(MAX)))
FROM
    mytable
Quassnoi