Reputation: 108
ALTER TABLE table1
ADD FOREIGN KEY attrib1 REFERENCES table2(attrib2)
GO
It works - but how can I drop it?
If I try
DROP FOREIGN KEY (attrib1) REFERENCES table2(attrib2)
it says
Incorrect syntax near the keyword 'FOREIGN'.
Upvotes: 0
Views: 856
Reputation: 220
In SQL Server you need to drop foreign key constraint by using below query:
Query :
ALTER TABLE [dbo].[Table_Name]
DROP CONSTRAINT [Constraint_Name]
Example:
ALTER TABLE [dbo].[SpeakerDetail]
DROP CONSTRAINT [FK_SpeakerId_UserID]
Upvotes: 2