Created
January 9, 2017 14:19
-
-
Save GER-NaN/9f8d9b7dffc8b4ddfadfdeffb25629dc to your computer and use it in GitHub Desktop.
Using HASHBYTES to calculate decent checksums on table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --Example hashbytes on states table | |
| --https://msdn.microsoft.com/en-us/library/ms174415.aspx | |
| --RoewLength and RowSize were added just for debugging purposes | |
| SELECT | |
| Id = tbl_states.state_id, | |
| Hash = HASHBYTES('MD5', (SELECT tbl_states.* FROM (VALUES(null))X(Y) FOR XML AUTO)), | |
| RowLength = LEN( (SELECT tbl_states.* FROM (VALUES(null))X(Y) FOR XML AUTO)), | |
| RowSize = DATALENGTH( (SELECT tbl_states.* FROM (VALUES(null))X(Y) FOR XML AUTO)) | |
| FROM | |
| tbl_states |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment