SELECT aa = ROW_NUMBER() OVER(ORDER BY GETDATE()), bb, cc FROM 表A
declare @i int set @i=0 update jqfx set [aa] = @i,@i=@i+1
使用临时表--sql 2000 select id = identity(int,1,1) into tmp , * from a truncate table a insert into a select id , bb , cc from tmp drop table tmp--sql 2005 select * from a truncate table a insert into a select row_number() over(order by bb , cc) , bb , cc from tmp drop table tmp
set @i=0
update jqfx
set [aa] = @i,@i=@i+1
select id = identity(int,1,1) into tmp , * from a
truncate table a
insert into a select id , bb , cc from tmp
drop table tmp--sql 2005
select * from a
truncate table a
insert into a select row_number() over(order by bb , cc) , bb , cc from tmp
drop table tmp