Table and Column Checksums
Posted
by Ricardo Peres
on ASP.net Weblogs
See other posts from ASP.net Weblogs
or by Ricardo Peres
Published on Tue, 01 Jun 2010 19:24:26 GMT
Indexed on
2010/06/01
19:25 UTC
Read the original article
Hit count: 306
SQL Server
|database
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:
© ASP.net Weblogs or respective owner