DBT drop command in azure sql database

The problem I’m having

Will this command works in dbt CLI ‘dbt drop-model <model_name>’ ?

The context of why I’m trying to do this

I removed model from my dbt project. Post that to drop it from my azure sql database, i executed the below query in dbt cli
‘dbt drop-model <model_name>’

But it doesn’t works.

Is it not possible to drop a object in database using dbt CLI?
Kindly assist me .

Thanks in Advance !

If you delete a model from your dbt project, dbt does not automatically drop the relation from your schema. This means that you can end up with extra objects in schemas that dbt creates, which can be confusing to other users.

When you remove models from your dbt project, you should manually drop the related relations from your schema.

if you want to drop table through dbt u have to create a macro to execute drop statement on warehouse


{% macro drop_model(database,schema,table_name) %}

{% set query %}
    DROP TABLE IF EXISTS {{database}}.{{schema}}.{{table_name}}
{% endset %}

{{log(query, info=true)}}
{% do run_query(query) %}

{% endmacro %}

then execute dbt run-operation --args '{database: database_name, schema: schema_name, table_name: table_name}'

If you want to clean up all removed models at once from your azure db please rerfer this article

Cleaning up removed models from your production schema