我这里有一个table,里面有个字段ID是自增的,从1.2.3......n
现在表里面存了2条记录,ID的最大值为2。而我手动的把ID值改为了20,改为20之后,3-19这段ID就没有记录了,而以后添加的记录ID就是以20为底数增加(21.22....n),我又添加了10条记录在里面,这时表的ID最大值就是30了。
现在要解决的问题就是:我把ID为20以后的记录删了,如何才能把记录的ID值让它还是以3为底数的增加呢?
各位大虾请指点指点。
现在表里面存了2条记录,ID的最大值为2。而我手动的把ID值改为了20,改为20之后,3-19这段ID就没有记录了,而以后添加的记录ID就是以20为底数增加(21.22....n),我又添加了10条记录在里面,这时表的ID最大值就是30了。
现在要解决的问题就是:我把ID为20以后的记录删了,如何才能把记录的ID值让它还是以3为底数的增加呢?
各位大虾请指点指点。
insert into #t select 20
insert into #t select 30
insert into #t select 40delete #t where num>=30--用dbcc checkident 重置当前标识值
dbcc checkident (#t,reseed,2)insert into #t select 50select * from #t
drop table #t
insert into T select 20
insert into T select 30
insert into T select 40
insert into T select 50delete T where num>=40
--用dbcc checkident 重置当前标识值
dbcc checkident (T,reseed,3)
insert into T select 60select * from T
drop table T