I want to update LastUpdatedOn datetime2
column every time a row is updated in a SQL Server table. To accomplish this, I was thinking of using an After Update
trigger to set LastUpdatedOn
to sysutcdatetime()
. This trigger is also responsible for detecting column changes and saving the old values to a history table. My question is, will the trigger approach save an accurate representation of the time a row is updated? Is there a time delay between an actual update vs. After Update
trigger updating LastUpdatedOn
?
Also, reading http://technet.microsoft.com/en-us/library/bb630387.aspx, it looks like GetSystemTimeAsFileTime()
may not be accurate across multiple servers. In a sharded database architecture with a lot of concurrent writes, what's the most reliable way to detect event times so that I know the order of events across the whole cluster is correct?
P.S. I've thought about using Change Data Capture
, but it's not available in SQL Azure.