一般没必要这么做!
如果你坚持的话:
先将数据导入临时表,以免出问题
select * into #temp from table
alter table #temp drop column id
alter table #temp add id int indentity(1,1)
delete from table insert into table select * from #temp
或者:
update table set id=b.id from table a,#temp b where a.name=b.name

解决方案 »

  1.   

    select * into #t from yourtable order by id
    go
    alter table #t
    drop column id
    go
    truncate table yourtable
    go
    insert into yourtable select * from #t
    go
      

  2.   

    CREATE TRIGGER trigger ON t 
    FOR DELETE 
    AS
    begin
    declare @i bigint
    select @i=序号 from deleted
    update t set 序号 =序号 -1 where 序号 >@i
    end
    用这个触发器,可以自动改变,就可以拉
      

  3.   

    select 除id字段  into #t from yourtable truncate table yourtableinsert into yourtable (除id字段 ) select * from #t
      

  4.   

    CREATE TRIGGER trigger ON t 
    FOR DELETE 
    AS
    begin
    declare @i bigint
    select @i=序号 from deleted
    update t set 序号 =序号 -1 where 序号 >@i
    end
    用这个触发器,可以自动改变,就可以拉
      

  5.   

    select * into #t from yourtable truncate table yourtableinsert into yourtable (除id字段 ) select 除id字段 from #t
      

  6.   

    alter table table_Name drop column idalter table table_Name add id int identity(1,1) with value