can we use checksum to check that row has been changed(sql server)?
sql, sql-server, sql-server-2008, t-sql
Solution
It is not safe, `CHECKSUM` could produce duplicates for different data.
In SQL Server, to check whether the row was changed in between, `ROWVERSION` (or it's synonim `TIMESTAMP`) is usually used, but you have to add it as a column to a table. This is not really a timestamp but rather simply a database-wide counter and is maintained automatically for every updated row. Note that it will change when an UPDATE statement is issued, the content actually may stay the same, as opposed to checksum.
Or you can roll your own real timestamp - add a datetime column of required precision and update it manually.
Problem
``` Create table Info ( Personid int, PersonNo int ) insert into Info(Personid,PersonNo) values(3,4) ``` Here we can see the checksum value of the particular row ``` Select CHECKSUM(Personid ,PersonNo ) from Info ``` Now i update the value of the PersonNo and check the checksum of the particular row CheckSum value has been changed so on this behalf i can know that particular row has been changed so my question is that Is this safe or accurate?