-- 建立测试表
create table #t(a varchar(20))
insert #t
select 'V000000000'
union select 'V000000001'
union select 'V000000006'
union select 'V000000008'
union select 'V000000009'
union select 'V000000012'
union select 'V000000050'
union select 'V000000056'
union select 'V000000086'
union select 'V000000112'-- 更新前
select * from #tdeclare @i int
set @i = -1
update #t set a = 'V000000' + right(('00' + cast(@i as varchar)),3),@i = @i +1-- 更新后
select * from #tdrop table #t

解决方案 »

  1.   

    declare @i int
    set @i = -1
    update t set 列 = 'V000000' + right(('00' + cast(@i as varchar)),3),@i = @i +1
      

  2.   

    试一下select * into 新表名 from 旧表名 order by 旧列名drop table 旧表名
      

  3.   

    看你给出的数据示例,不象是要按顺序排列,而是要改成不跳号的顺序记录。如果真是这样,建议你干脆不要这一列,只定义一个自增列就行了。查询结果时再计算此列就行。
    select 'V'+right('00000000'+cast(   (   select sum(1) as a 
                                                from table1 
                                                where id<=b.id
                                         ) as varchar(8)
                                    ),8
                    ) as vcol,
                         col2,
                         ...  
    from table1 b 
    order by id