If an identity column exists for a table with frequent deletions, gaps can occur between identity values. If this is a concern, do not use the IDENTITY property. However, to ensure that no gaps have been created or to fill an existing gap, evaluate the existing identity values before explicitly entering one with SET IDENTITY_INSERT ON.这是由删除数据引起的,indentity不会自动补充空白。是正常的,
create table t(id int identity(1,1),name varchar(10)) go--添加数据 insert into t values( 'aa') go--中途被修改了自增种子 set identity_insert t on insert into t(id,name) values(132644,'bb') set identity_insert t off go--再次插入时 insert into t values( 'cc') go--查看结果: select * from t/*结果 id name ----------- ---------- 1 aa 132644 bb 132645 cc */
http://blog.csdn.net/xys_777/archive/2010/07/22/5755762.aspx
go--添加数据
insert into t values( 'aa')
go--中途被修改了自增种子
set identity_insert t on
insert into t(id,name) values(132644,'bb')
set identity_insert t off
go--再次插入时
insert into t values( 'cc')
go--查看结果:
select * from t/*结果
id name
----------- ----------
1 aa
132644 bb
132645 cc
*/