Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

If exist in Constraint Drop Expand / Collapse
Author
Message
Posted Wednesday, February 25, 2009 1:45 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, February 26, 2009 6:43 AM
Points: 1, Visits: 5
I have the following procedure that's suppose to drop a constraint. How do I add the If exist clause:

EXECUTE IMMEDIATE 'ALTER TABLE MCCOYS.CUSTOMER_RICH_CONTACTS DROP' ||
'CONSTRAINT CUSTOMER_RICH_CONTACTS_RO1';
Post #664590
Posted Thursday, February 26, 2009 1:30 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:57 AM
Points: 43,045, Visits: 36,205
ray.gabriel (2/25/2009)

EXECUTE IMMEDIATE

That doesn't look like T-SQL.

If it is T-SQL, checks are done like this

IF EXISTS (SELECT 1 from sys.objects where name = 'CUSTOMER_RICH_CONTACTS_RO1')
ALTER TABLE MCCOYS.CUSTOMER_RICH_CONTACTS DROP CONSTRAINT CUSTOMER_RICH_CONTACTS_RO1




Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #664835
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse