Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to drop foreign constraints of table having foreign key constraints with Hyphen in Sql

I am getting exception while dropping FK Constraints as shown below:


ALTER TABLE AB_Test DROP CONSTRAINT FK_AB-Test_1


Exception is as below:

Incorrect Syntax near '-'

What I have tried:

ALTER TABLE AB_Test DROP CONSTRAINT FK_AB-Test_1


Exception is as below:

Incorrect Syntax near '-'
Posted
Updated 26-Mar-18 2:58am
v2
Comments
Rajesh Pandya 26-Mar-18 8:41am    
Have a look at following URL, may be it will help
URL: https://dba.stackexchange.com/questions/90033/how-do-i-drop-all-constraints-from-all-tables

1 solution

You'll need to wrap the constraint with brackets.

SQL
ALTER TABLE AB_Test DROP CONSTRAINT [FK_AB-Test_1]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900