SQL语句添加,删除主键

IF EXISTS (SELECT * FROM sys.all_objects  WHERE  type_desc= N'主键名')
begin 

--删除主键
 alter table 表名 drop constraint  主键名
alter table 表名 add constraint 主键名 primary key (字段名)
end

原文地址:https://www.cnblogs.com/fangmin/p/3519418.html