hashbytes

/*
Checksum() isnt very good for detecting data changes. Use hashbytes() instead
Example of output from script below:
-361975519341300.801789
*/


select avg(cast(cast(hsh as bigint) as decimal(25,0))) as truncatedHash
from (
select cast(HASHBYTES('SHA1',
[StringField1]+
[StringField2]+
[StringField3]) as binary(20)) as hsh
FROM dbo.TableToBeInvestigated
) as hashedData

Comments

Popular posts from this blog

SSIS: Set parent package variable from child package

How to decrypt stored password from SSMS registered servers

Insert bulk statement does not support recompile (SQL 2017)