File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
dbt/include/sqlserver/macros/adapters Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 15
15
{% macro sqlserver__drop_relation_script(relation) - %}
16
16
{% call statement(' find_references' , fetch_result= true) %}
17
17
USE [{{ relation .database }}];
18
- SELECT referencing_schema_name, referencing_entity_name
19
- FROM sys .dm_sql_referencing_entities (' {{ relation.include(database=false) }}' , ' object' )
18
+ select
19
+ sch .name as schema_name,
20
+ obj .name as view_name
21
+ from sys .sql_expression_dependencies refs
22
+ inner join sys .objects obj
23
+ on refs .referencing_id = obj .object_id
24
+ inner join sys .schemas sch
25
+ on obj .schema_id = sch .schema_id
26
+ where refs .referenced_database_name = ' {{ relation.database }}'
27
+ and refs .referenced_schema_name = ' {{ relation.schema }}'
28
+ and refs .referenced_entity_name = ' {{ relation.identifier }}'
29
+ and refs .referencing_class = 1
30
+ and obj .type = ' V'
20
31
{% endcall %}
21
32
{% set references = load_result(' find_references' )[' data' ] %}
22
33
{% for reference in references - %}
You can’t perform that action at this time.
0 commit comments