开发者

Hash Code in SQL Server?

开发者 https://www.devze.com 2022-12-20 19:13 出处:网络
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 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.


SELECT
    HASHBYTES('MD5', CAST(col1 AS VARBINARY(MAX)) + 
        CAST(col2 AS VARBINARY(MAX)))
FROM
    mytable
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号