[Sql Server]删除主键约束

-- if the table name is 'gtp_product_po_tnx'
declare @PK varchar(100)
select @PK=name from sysobjects where xtype='PK' and parent_obj=object_id('gtp_product_po_tnx')
exec ('alter table gtp_product_po_tnx drop CONSTRAINT '+@PK)
GO
-- done

你可能感兴趣的:(数据库)