sql-servertimevector-clock

SQL Server vector clock


Is there a global sequence number in SQL Server which guarantees to increment periodically (even when system time regresses), and can be accessed as part of an insert or update operation?


Solution

  • Yes the rowversion data type, and the @@dbts function are what you're looking for.

    This pattern, of marking rows using a rowversion is implemented at a lower level by the Change Tracking feature. Which adds tracking of insert/updates and deletes, and doesn't require you to add a column to your table.