34,588
社区成员
发帖
与我相关
我的任务
分享
if OBJECT_ID('test') is not null
drop table test
go
create table test(id varchar(3),value int, constraint pk_id primary key (id))
insert into test values ('A', 1),
('B', 2),
('D', 3),
('E', 4),
('F', 5),
('G', 6)
--create clustered index clu_id on test(id)
insert into test(id) values('C')
update test set value=row from test t1 join(
select id,ROW=ROW_NUMBER()over(order by id) from test
)as t2 on t1.id=t2.id
select * from test