Thursday, March 22, 2012

Detecting whether table contents have changed

If I start with table1 and take a copy of it, call it table2.
How can I later determine whether there have been any changes have been made to table2 since the copy (so I can determine whether I need to copy back the changes to table1).

I'd like to use a 'last-updated-date' on the table, but I can't seem to find anything like that in the system tables.

I'm considering using:
exec sp_table_validation
to get checksums of table1 and table2 (I have no image, text or ntext fields) so this should work fine, though might be slow (since I'd have to select the full count(*) option).
I'd prefer to use timestamps if they're available.

And no, I don't want to use triggers.

Thanks,

- Andy AbelOther than using to trigger to *log* changes, you would have to do a full table *scan* to find the differences. This sure would take a long time to step through a large table.

No comments:

Post a Comment