I've got a situation where I am using a RowVersion columns and a Binary(8) columns to track whether a row has been changed.
Ideally whenever:
RowVersion != Binary(8)
Then there has been a change in that record. The real problem with this is that I cannot find a good method to set the two columns to equal. If I update the Binary field, the update query increments the RowVersion field for that record. I'v messed with optimistically incrementing the Binary field, and it almost works. The key is I have to increment the Binary field by the total number of records that the UPDATE query will affect. Any idea on how to pause the rowversion, or determine what it will be at the end of an update statement to use the value IN the update statement?
For clarity, here's an example of what will work to make the two fields match:
UPDATE [table] SET BinaryField = MyRowVersion +
(SELECT COUNT(*) FROM [table] WHERE (MyRowVersion != BinaryField))
WHERE (MyRowVersion != BinaryField)