I know that the value itself for a RowVersion
column is not in and of itself useful, except that it changes each time the row is updated. However, I was wondering if they are useful for relative (inequality) comparison.
If I have a table with a RowVersion
column, are either of the following true:
RowVersion
column?Thanks.
Each database has a counter that is incremented for each insert or update operation that is performed on a table that contains a rowversion
column within the database. This counter is the database rowversion
. This tracks a relative time within a database, not an actual time that can be associated with a clock. Every time that a row with a rowversion
column is modified or inserted, the incremented database rowversion
value is inserted in the rowversion
column.
http://msdn.microsoft.com/en-us/library/ms182776.aspx
rowversion
s should be unique. I venture to say that they would be effectively useless if duplicates were allowed within the same table. Also giving credance to rowversion
s not being duplicated is MSDN's stance on not using them as primary keys not because it would cause violations, but because it would cause foreign key issues.To the question of how much it increments, MSDN states, "[rowversion
] tracks a relative time within a database" which indicates that it is not a fluid integer incrementing, but time based. However, this "time" reveals nothing of when exactly, but rather when in relation to other rows a row was inserted/modified.