Generate a hash for a set of rows in sql server

前端 未结 4 738
春和景丽
春和景丽 2021-01-17 12:24

Is there any way in SQL Server 2012 to generate a hash of a set of rows and columns?

I want to generate a hash, store it on the parent record. The when an update co

4条回答
  •  长情又很酷
    2021-01-17 12:46

    For single row hashes:

    select HASHBYTES('md5', Name + Description + AnotherColumn)
    FROM MyChildTable WHERE ParentId = 2
    

    for table checksum:

    select sum(checksum(Name + Description + AnotherColumn)*1.0)
    FROM MyChildTable WHERE ParentId = 2
    

提交回复
热议问题