How to prevent timestamp field from been automatically updated for an update

  • I have a table with a timestamp field

    1- Someone get a row

    2- My random running thread get a row then modify a logically private field (DataSent bit)

    3- The Someone save the row but timestamp has changed

    In step 2 I'd like my SP to update in a way that prevent timestamp refresh

    like SET PreventTimestamp = 1

    I do not want answers like: Do another table...

  • Hello Alain,

    timestamp is a  data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.

    A table can have only one timestamp column. The value in the timestamp column is updated every time a row containing a timestamp column is inserted or updated. This property makes a timestamp column a poor candidate for keys, especially primary keys. Any update made to the row changes the timestamp value, thereby changing the key value. If the column is in a primary key, the old key value is no longer valid, and foreign keys referencing the old value are no longer valid. If the table is referenced in a dynamic cursor, all updates change the position of the rows in the cursor. If the column is in an index key, all updates to the data row also generate updates of the index.

     


    Lucky

  • I know all that. I want something similar to a c++ mutable field i.e. that field modification would inhibit the RowVersion (Timestamp auto process).

    Thank you anyway

  • Another option is to change the data type to Binary and manage the timestamp column on your own. you can get the next timestamp value for your db using this function @@DBTS.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply