id  data
1    a
2    b
3    d
把3个数据都删除后,再插入新数据,id将是4开始,请问怎么重新从1开始?谢谢

解决方案 »

  1.   

    我没说清楚,不好意思。
    id data
    1 a
    2 b
    3 d
    把后2个数据都删除后,再插入新数据,id将是4开始,请问怎么重新从1开始?
      

  2.   

    SET IDENTITY_INSERT table1 ON
      

  3.   

    create table table1(id int identity(1,1),data char(1))
    insert into table1(data)
    select 'a'
    union select 'b'
    union select 'd'
    select * from table1
    delete from table1 where id>1
    go
    SET IDENTITY_INSERT table1 ON
    insert into table1(id,data) select 2,'e' union select 3,'f'
    go
    select * from table1
    drop table table1;