3729: Cannot DROP because it is being referenced by object
SQL ServerWhat 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.
More from this engine
- 50000Custom error raised with RAISERROR
- 3902The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION
- 1101Could not allocate a new page because of insufficient disk space in filegroup
- 3961Snapshot isolation transaction failed because the object was modified by a DDL statement
- 1785Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths
- 9421XML parsing: illegal xml character
- 15151Cannot find the object/principal because it does not exist or you do not have permission