Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a record without changing rowversion

If a table has a rowversion column in it and you make an update to that row, the value of the rowversion column increases. I know that this is by design and the purpose of rowversion columns, however is there any way to make it such that an update operation will have no effect on rowversion value?

Edit: Tracking of updates on all columns is required, however there are some operations that we would like to avoid being perceived as new versions.

like image 467
wnka Avatar asked Oct 15 '08 02:10

wnka


People also ask

How do you update an existing SQL record?

The UPDATE command in SQL is used to modify or change the existing records in a table. If we want to update a particular value, we use the WHERE clause along with the UPDATE clause. If you do not use the WHERE clause, all the rows will be affected.

Is Rowversion the same as timestamp?

timestamp is the synonym for the rowversion data type and is subject to the behavior of data type synonyms. In DDL statements, use rowversion instead of timestamp wherever possible. For more information, see Data Type Synonyms (Transact-SQL).

Is it possible to update records in a table?

SQL gives users the option to update existing records in tables with the help of the UPDATE command. Using this command, you can change and alter some (or all) of the records from single or multiple columns of a table.

How do I update my record in view?

To modify table data through a view. In Object Explorer, expand the database that contains the view and then expand Views. Right-click the view and select Edit Top 200 Rows. You may need to modify the SELECT statement in the SQL pane to return the rows to be modified.


2 Answers

No. See MSDN. "Every time that a row with a rowversion column is modified or inserted, the incremented database rowversion value is inserted in the rowversion column."

like image 151
tvanfosson Avatar answered Oct 12 '22 23:10

tvanfosson


No, but perhaps you mean to use auto-increment? Then you have a new unique number when the row is created but it doesn't change when the row is updated.

If you also wanted some kind of change-counter that didn't apply to all columns you could then implement that yourself in another column.

like image 25
Jason Cohen Avatar answered Oct 13 '22 01:10

Jason Cohen