Link to home
Start Free TrialLog in
Avatar of Jim Horn
Jim HornFlag for United States of America

asked on

DROP every constraint

Hi guys

Question:  When you drop a table, how do you ensure that you drop every constraint on the table first?

<pseudo code>

IF OBJECT_ID('log.EXECUTIONS','U') IS NOT NULL
      begin
      ALTER TABLE log.EXECUTIONS DROP CONSTRAINT <every friggin' constraint on the table>   --  <--  Here
      DROP TABLE log.EXECUTIONS
      end
GO

Thanks in advance.
Jim
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jim Horn

ASKER

I changed the order of my DROPS so that all the children were dropped first, then the parent, and I no longer get these messages.
I'm going to wait a couple of days to make sure that is correct.

Thanks.
Jim
Haven't had a chance to circle back to this, sorry, but reordering the DROPs based on child-parent order seems to have worked.  Thanks.