List objects that use specific object in SQL Server database

Article for: Azure SQL Database Oracle database

Query below lists all objects that are referencing to specific object .


select schema_name(obj.schema_id) +  '.' +
        + case when referenced_minor_id = 0 then ''
               else '.' + end as referenced_object,
       'referenced by' as 'ref',
       schema_name(ref_obj.schema_id) as referencing_schema, as referencing_object_name,
       case when ref_obj.type_desc = 'USER_TABLE' 
                 and dep.referencing_minor_id != 0
            then 'COLUMN'
            else ref_obj.type_desc end as referencing_object_type, as referencing_column
from sys.sql_expression_dependencies dep
join sys.objects obj
     on obj.object_id = dep.referenced_id
left join sys.columns col
     on col.object_id = dep.referenced_id
     and col.column_id = dep.referenced_minor_id
join sys.objects ref_obj
     on ref_obj.object_id = dep.referencing_id
left join sys.columns ref_col
     on ref_col.object_id = dep.referencing_id
     and ref_col.column_id = dep.referencing_minor_id
where schema_name(obj.schema_id) = 'Sales'  -- put object schema name here
      and = 'SalesOrderHeader'     -- put object name here
order by referencing_schema,


  • referenced_object - provided schema name, object name and eventually automaticlly added column
  • ref - string 'referenced by'
  • referincing_schema - schema name of the referencing object
  • referencing_object_name - name of the referencing object
  • referencing_object_type - type of the referencing object
  • referencing_column - computed column name


  • One row represents one depending object
  • Scope of rows: all objects that are depending on specified object
  • Ordered by referencing object schema name and name

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.