I want to check if a constraint exists before attempting to drop it, so that my script is re-runable and does not throw up error messages when the constraint does not exist.I have tried the following:IF EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ED_FCA]') AND parent_object_id = OBJECT_ID(N'[dbo].[ED]')) BEGIN ALTER TABLE [dbo].[ED] DROP CONSTRAINT [DF_ED_FCA] ENDIF (SELECT COALESCE(COL_LENGTH('ED','FCA'),0)) <> 0 BEGIN ALTER TABLE Test.dbo.ED DROP COLUMN FCA ENDELSE PRINT '**** ED.FCA does not exist ****'GO
When i run this i get the following error messagesMsg 5074, Level 16, State 1, Line 20The object 'DF_ED_FCA' is dependent on column 'FCA'.Msg 4922, Level 16, State 9, Line 20ALTER TABLE DROP COLUMN FCA failed because one or more objects access this column.