SQL SERVER: What is CHECKSUM
FROM HELP FILE
CHECKSUM computes a hash value, called the checksum, over its list of arguments. The hash value is intended for use in building hash indices. If the arguments to CHECKSUM are columns, and an index is built over the computed CHECKSUM value, the result is a hash index, which can be used for equality searches over the columns.
We can easily detect if there is a changes in any rows in any places ( in any particular fields)
-----------Example---------
use pubs
SELECT au_id , au_lname ,
CHECKSUM ( au_id , au_lname ) AS chk
FROM authors
--409-56-7008 Bennet 271639220
update authors set au_lname = 'Bennet' where au_id = '409-56-7008'
SELECT au_id , au_lname ,
CHECKSUM ( au_id , au_lname ) AS chk
FROM authors
--409-56-7008 Bennet 271639220( No changes in checksum )
update authors set au_lname = 'Bennnet' where au_id = '409-56-7008'
SELECT au_id , au_lname ,
CHECKSUM ( au_id , au_lname ) AS chk
FROM authors
--409-56-7008 Bennnet -1628839244( Checksum changed )
update authors set au_lname = 'Bennet' where au_id = '409-56-7008'
SELECT au_id , au_lname ,
CHECKSUM ( au_id , au_lname ) AS chk
FROM authors
--409-56-7008 Bennet 271639220 ( Again the check sum is the same )
---: I am not responsible for any damages happened from the suggestion of my blog :---
Reach me at : m.a.hasim@inbox.com
Labels: Technical_HowTo_SQLSERVER
0 Comments:
Post a Comment
<< Home