开发者

Checking for Constraint

I need to write a SQL script 开发者_StackOverflow中文版to ensure that a constraint is existing.

If the constraint exists, I will be dropping the constraint. How to achieve this?


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

You need Schema.constraintname to correctly resolve schema. You could have 2 PK_foo objects if you have tables this.foo and that.foo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜