I'm trying this code
Drop Table Inventory
I get error:
Could not drop object 'Inventory' because it is referenced by a FOREIGN KEY constraint.
I'm trying this code
Drop Table Inventory
I get error:
Could not drop object 'Inventory' because it is referenced by a FOREIGN KEY constraint.
First you have to Drop
the table's constraints and then table
SELECT
'ALTER TABLE ' + OBJECT_SCHEMA_NAME(parent_object_id) +
'.[' + OBJECT_NAME(parent_object_id) +
'] DROP CONSTRAINT ' + name
FROM sys.foreign_keys
WHERE referenced_object_id = object_id('Inventory')
Drop Table Inventory
use this
DROP TABLE Inventory CASCADE CONSTRAINTS;
You need to Drop the Constraint first..
ALTER TABLE [dbo].[t2] DROP CONSTRAINT [foreign key constraint]
then You can Drop the table
Drop table t1
Just try this
ALTER TABLE Inventory NOCHECK CONSTRAINT all
DROP TABLE Inventory
drop the foreign key constraint from subtable and then drop the main table