I have a table with a whole bunch of FKs.
Table Vehicles
-----------
ColorID -> Color.ID
MakeID -> Make.ID
ModelID -> Model.ID
etc...
My issue is that I forgot a few columns and I need to add them. I can add them through right clicking on the table and choosing 'Design', but not if I want to make them NOT NULL, or delete a column. I could also generate a Drop/Create Script, but I get this Error:
Msg 3726, Level 16, State 1, Line 4
Could not drop object 'dbo.SellVehicles' because it is referenced by a FOREIGN KEY constraint.
Do I need to go through and remove each FK and then drop/create, then add them back or is there a quick/painless way of doing this? Is there a way to drop and recreate these FKs quickly?
Why doesn't
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SellVehicles_Conditions]') AND parent_object_id = OBJECT_ID(N'[dbo].[SellVehicles]'))
ALTER TABLE [dbo].[SellVehicles] DROP CONSTRAINT [FK_SellVehicles_Conditions]
GO
eliminate this error? Is the FK still on the other table being referenced?