|
Posted by Erland Sommarskog on 05/30/07 21:57
Kurt (nicolas.agrapart@gmail.com) writes:
> I read on the msdn website that BINARY_CHECKSUM can be used to detect
> changes to a row of a table.
> To update my current tables, I truncate and after I insert the new
> datas.
> What do you call a timestamp ? How timestamp could work for me ?
If you truncate and insert, timestamp is not going help you. A timestamp
column is automatically updated when a column is updated with a database-
unique monotonically increasing value. So if you had updated only rows that
had changed, and inserted new ones, you could have saved the current
timestamp value when you started, and then all rows with a higher timestamp
value would have been new.
But since you truncate and re-insert, all timestamp values will be higher
when you started.
As I recall binary_checksum() returns a 32-bit integer. If your tables
are wide, this means that collisions will not at all be unlikely. Note
also that binary_checksum ignores some data types entirely.
While more boring to code, I would recommend that you make a comparison
column by column.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|