--删除主键 Declare @Pk varChar(100); Select @Pk=Name from sysobjects where Parent_Obj=OBJECT_ID(‘SwtoolsUpdateRecord‘) and xtype=‘PK‘; if @Pk is not null exec(‘Alter table SwtoolsUpdateRecord Drop ‘+ @Pk) --重新设置主键 ALTER Table SwtoolsUpdateRecord ADD CONSTRAINT pkName PRIMARY KEY (ID) --查看当前主键值 DBCC CHECKIDENT (SwtoolsUpdateRecord) --将当前主键值归0 DBCC CHECKIDENT (SwtoolsUpdateRecord, RESEED, 0)