首页 > 代码库 > SQL删除主键

SQL删除主键

 

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

 

SQL删除主键