开发者

Checking for Constraint

开发者 https://www.devze.com 2023-01-28 19:43 出处:网络
I need to write a SQL script 开发者_StackOverflow中文版to ensure that a constraint is existing.

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

精彩评论

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