2010-12-02 129 views
0

我需要编写一个SQL脚本以确保约束存在。检查约束

如果约束条件存在,我将删除约束条件。 如何做到这一点?

回答

2
IF OBJECT_ID('Schema.constraintname') IS NOT NULL 
    ALTER TABLE Schema.foo DROP constarintname 

您需要Schema.constraintname才能正确解析模式。如果您有表this.foothat.foo

您可以有2 PK_foo对象