Back to previous

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'

ShareThis

If you think this post is useful, please recommend me at the bottom of the page. ;)

Discussion