In this Azure SQL tutorial, I will explain how I encountered the error “cannot drop schema because it is being referenced by object” and how did I resolve it.
Cannot drop schema because it is being referenced by object
I was trying to delete a schema in Azure SQL database using the DROP SCHEMA statement. Below is the T-SQL code that I was trying to execute:
DROP SCHEMA Production
Production was the schema name. After executing the above query I got the error “failed to execute query. Error: Cannot drop schema ‘Production’ because it is being referenced by object ‘Items’” as shown below in the image:

Solution: Cannot drop schema because it is being referenced by object
I searched about this error on the web and found the reason for this error message.
We cannot drop a schema until all the objects under the schema are not deleted.
In my case, the Items object was a table created under the Production schema.
Therefore I firstly dropped all the objects like tables, stored procedures, and functions under the Production schema. Then I executed the query to drop the Production schema and the query got executed successfully.

In this way. I was able to resolve the error “Cannot drop schema because it is being referenced by object“. It will also fix, cannot drop schema because it is being referenced by object sql server error.
Related Azure SQL tutorials:
- Cannot open backup device operating system error 50 azure
- Backup and restore SQL Server to Azure Blob storage
- Azure sql password validation failed
- Configuring email notifications in Azure SQL database
- Cannot bulk load because the file could not be opened. operating system error code (null). azure

Rajkishore Sahoo is a Microsoft Azure consultant with more than 14 years of hands-on experience building cloud-native data solutions across Azure and AWS, focused on Azure SQL Database, Azure SQL Managed Instance, and the pipelines that connect them to production apps. Day to day, he provisions Azure SQL instances, configures firewalls and connection strings, tunes queries for cloud workloads, and wires databases into Azure Functions and Logic Apps. Read more