日期:2014-05-17 浏览次数:20824 次
declare @表A table (a int,b varchar(2),c varchar(2))
insert into @表A
select 1,'ff','gg' union all
select 4,'bb','cc' union all
select 7,'aa','hh'
;with maco as
(
select row_number() over (order by a) as id,* from @表A
)
select * from maco
/*
id a b c
-------------------- ----------- ---- ----
1 1 ff gg
2 4 bb cc
3 7 aa hh
*/
declare @表A table (a int,b varchar(2),c varchar(2))
insert into @表A
select 1,'ff','gg' union all
select 4,'bb','cc' union all
select 7,'aa','hh'
;with maco as
(
select row_number() over (order by a) as id,* from @表A
)
update maco set a=id
select * from @表A
/*
a b c
----------- ---- ----
1 ff gg
2 bb cc
3 aa hh
*/