SQL: Could not drop object

Published by

Posted on August 11, 2008

Could not drop object ‘dbo.tablename’ because it is referenced by a FOREIGN KEY constraint. (.Net SqlClient Data Provider)

Type “sp_help tablename” in a query analyzer. In the last row of the result list, you will find a list of tables which has refered Mytable as primary key;

Go to those tables and drop those foreign keys (or use Alter Table table table_name drop constraint your_FK_name)

added note:

The keys must be drop before you can remove the table.