Click here to Skip to main content
15,888,253 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I type the following statement in SQL server 2008 to drop a foreign key.

SQL
ALTER TABLE BOOK DROP FOREIGN KEY (FK_AUTHOR_NUMBER)


But after executing the command I got the following error.



Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'FOREIGN'.



Please try to solve my doubt! Thanx
Posted
Updated 21-Apr-20 10:10am

Write the CONSTRAINT name in the query
Refer this link
http://www.techonthenet.com/oracle/foreign_keys/drop.php[^]
 
Share this answer
 
hi,

alter table t2 drop constraint [FK_t2_t2]

drop constraint [constrint_name]
 
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