BINARY_CHECKSUM function is used to detect changes to a row of a table.
It returns the binary checksum value computed for row of a table or list of
expressions.
BINARY_CHECKSUM function ignores noncomparable data types in its computation. Noncomparable
data types are text, ntext, image, and cursor, sql_variant with any of
the above types as its base type.
BINARY_CHECKSUM(*)
computed on any row of a table returns the same value as long the row is not
subsequently modified.
Note that the order of expressions affects the resultant value.
Syntax of BINARY_CHECKSUM function :
BINARY_CHECKSUM ( * | expression [ ,...n ] )
* means
that the computation is over all the columns of the table.
Expression is any valid sql expression of any type.
BINARY_CHECKSUM ignores expressions of noncomparable data types in its
computation.
Example
of BINARY_CHECKSUM function :
Example 1 : Use of BINARY_CHECKSUM function to detect changes in the row
of a table in SELECT clause
SELECT ProductID, BINARY_CHECKSUM(*)
AS 'Binary Checksum'
FROM Products
Output
ProductID Binary Checksum
1 739373310
2 1240574164
3 -1469771421
4 1424280107
5 192100513
Above example displays checksum of rows modified in the products table.