Table and Column Checksums
- by Ricardo Peres
Following my last posts on Change Data Capture and Change Tracking, here is another tip regarding tracking changes: table and colum checksums. The concept is: each time a column value changes, the checksum also changes. You can use this simple method to see if a table has changed very easily, however, beware, different column values may generate the same checksum. Here's the SQL:
-- table checksum
SELECT CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM TableName
-- column checksum
SELECT CHECKSUM_AGG(BINARY_CHECKSUM(ColumnName)) FROM TableName
-- integer column checksum
SELECT CHECKSUM_AGG(IntegerColumnName) FROM TableName
Here are the reference links on the CHECKSUM, CHECKSUM_AGG and BINARY_CHECKSUM functions:
CHECKSUM
CHECKSUM_AGG
BINARY_CHECKSUM
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf';
SyntaxHighlighter.brushes.Xml.aliases = ['xml'];
SyntaxHighlighter.all();