博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

SQL SERVER 将某列数据更新为数据序列

Posted on 2006-09-22 16:59  liufu627  阅读(454)  评论(0)    收藏  举报
将某列数据更新为数据序列
主表
create table la
(
 id  int identity(0, 1 )

, name varchar(10)
,ids int
)
再插入一些数据
insert into  la
( name
 )
select 'a'
union select 'b'
union select 'bsd'
union select 'bsf'
union select 'bsf'
union select 'bf'
union select 'basdf'
union select 'ba'
union select 'bdsf'


序列表
select cast( id as varchar) as id , identity(int, 0 , 1 ) idd  into lb from la

再然后更新
update la
set ids = lb.idd
from la , lb
where la.id = lb.id