SQL Server自增ID值不连续记录的实现方法

复制if exists (select * from sysobjects where id = OBJECT_ID([t_IDNotContinuous]) and OBJECTPROPERTY(id,自增ID值 IsUserTable) = 1) DROPTABLE [t_IDNotContinuous] CREATETABLE [t_IDNotContinuous] ( [ID] [int] IDENTITY (1, 1) NOTNULL, [ValuesString] [nchar] (10) NULL) SET IDENTITY_INSERT [t_IDNotContinuous] ON INSERT [t_IDNotContinuous] ([ID],[ValuesString]) VALUES ( 1,test) INSERT [t_IDNotContinuous] ([ID],[ValuesString]) VALUES ( 2,test) INSERT [t_IDNotContinuous] ([ID],[ValuesString]) VALUES ( 3,test) INSERT [t_IDNotContinuous] ([ID],[ValuesString]) VALUES ( 5,test) INSERT [t_IDNotContinuous] ([ID],[ValuesString]) VALUES ( 6,test) INSERT [t_IDNotContinuous] ([ID],[ValuesString]) VALUES ( 7,test) INSERT [t_IDNotContinuous] ([ID],[ValuesString]) VALUES ( 10,test) SET IDENTITY_INSERT [t_IDNotContinuous] OFF select * from [t_IDNotContinuous] 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.