I want to add a rowversion column to an existing table in my database so I can essentially order by the last time each record was modified successfully. My question is, how will adding the rowversion affect my existing data? Will the rowversion values be assigned like random on these records or by the last instance they were modified too? (Even though they existed before the column)
My question is, how will adding the rowversion affect my existing data?
You can test it.
eg
drop table if exists t
go
create table t(id int primary key)
insert into t(id) values (1),(2),(3)
go
alter table t add rv rowversion
go
insert into t(id) values (4)
insert into t(id) values (5),(6)
go
select * from t
outputs
(3 rows affected)
(1 row affected)
(2 rows affected)
id rv
----------- ------------------
1 0x00000000000007DD
2 0x00000000000007DE
3 0x00000000000007DF
4 0x00000000000007E0
5 0x00000000000007E1
6 0x00000000000007E2
(6 rows affected)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.