DBAtlas · Database operations atlas

3729: Cannot DROP because it is being referenced by object

SQL Server

What does it mean?

The object you want to drop (table, type, function etc.) is referenced by another object, and that dependency prevents the drop. Schema-bound objects in particular are protected this way.

Why does it happen?

Trying to drop a table/object that a view or function created WITH SCHEMABINDING depends on; dropping a table referenced by a foreign key; or removing a user-defined type while a table/parameter still uses it.

How to fix it

Drop the referencing objects or remove the dependency first. To find dependencies: SELECT referencing_schema_name, referencing_entity_name FROM sys.dm_sql_referencing_entities('app_schema.object', 'OBJECT'); For schema-bound views, first remove SCHEMABINDING with ALTER VIEW or drop the view, then drop the table.

Open in DBAtlas →

More from this engine