2

I would like to run following command without Rowversion (timestamp) column values changed. I would like to achieve this both on SQL Server 2008 R2 and SQL Server CE 4.0.

ALTER TABLE MyTable 
ALTER COLUMN TextColumn nvarchar(4000) --original size 2000

Columns in MyTable

Version rowversion NOT NULL
TextColumn nvarchar(2000) NOT NULL

No data in MyTable. TextColumn change by running this command, still all the rowversion values are updated, which is definitely not the expected behavior.

Is this possible or is there any workaround?

Edit:

To make it more clear I should add that the my purpose is to distribute db structure updates in a synchronized environment, where the server is SQL Server 2008 R2 and sync clients are SQL CE 4.0.

Edit 2: This problem is present only on SQL Compact. On normal SQL Server it works as expected.

Edit 3: Filled as a bug on Microsoft Connect: https://connect.microsoft.com/SQLServer/feedback/details/816991/unexpected-sql-ce-4-0-rowversion-value-behavior-with-alter-column

Vojtěch Dohnal
  • 7,867
  • 3
  • 43
  • 105
  • You say that all values are changed, but also that there is no data in the table, which one is it?? – ErikEJ Feb 03 '14 at 17:08
  • @ErikEJ It means, that when I change the column size from 2000 to 4000 then the actual data in the text column do not change - all the values in the column remain the same since it is not nchar but nvarchar – Vojtěch Dohnal Feb 04 '14 at 07:22
  • @marc_s Not true. Table alterations (as truly administrative tasks) might usually not be meant to change the timestamp. Furthermore an ALTER TABLE with impact on TIMESTAMP could raise problems in replication/synchronization setups: In such setups, ALTER TABLE is usually done at different times at different locations for the same (distributed) rows, and that would lead to multiple changes of the timestamp column for the same row. That might be difficult to handle. http://sqlanywhere-forum.sybase.com/questions/1599/does-alter-table-impact-default-timestamp-columns – Vojtěch Dohnal Feb 04 '14 at 07:28

1 Answers1

2

I am able to repro your issue, and do not know of any workaround. One option would be to rely on something else than rowversion values for sync purposes.

ErikEJ
  • 40,951
  • 5
  • 75
  • 115