Checking for Constraint
I need to write a SQL script 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