How to check if Constraint exist

A very useful statement to check if a constraint exists before do something to it. Note, we can never edit a constraint before deleting it and re-create.

SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA=’dbo’
AND CONSTRAINT_NAME=’FK_37_Page_FK’ AND TABLE_NAME=’PageContent’

Categories: SQL
Tags: