John Saraka
asked on
calculate MD5 or SHA checksum of each row from table fields
How to calculate MD5 or SHA checksum of each row from table fields in SSIS
You may use HASHBYTES() T-SQL function and pass the concatenated columns as a parameter to it. You may use CONCAT() function to concatenate selected columns.
pcelba provides the solution, but expand for people looking into this and to give caution/context, you can use CHECKSUM or BINARY_CHECKSUM to generate a checksum for a row which I have seen in some databases. While easier to work with, this is not the correct approach and your approach with generating a hash is the correct way (I would go at least SHA1 to avoid collisions).
Using CHECKSUM or BINARY CHECKSUM you will have collisions, lots of them. For example:
Using CHECKSUM or BINARY CHECKSUM you will have collisions, lots of them. For example:
SELECT CHECKSUM(1.23),CHECKSUM(-1.23)
both have a result of 2001159322. So don't use these for any data version type requirement.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
ASKER