Find where specific stored procedure is used in SQL Server database

Article for: Azure SQL Database Oracle database

Query below list objects where specific procedure is used.

Query

select schema_name(o.schema_id) + '.' + o.name as [procedure],
       'is used by' as ref,
       schema_name(ref_o.schema_id) + '.' + ref_o.name as [object],
       ref_o.type_desc as object_type
from sys.objects o
join sys.sql_expression_dependencies dep
     on o.object_id = dep.referenced_id
join sys.objects ref_o
     on dep.referencing_id = ref_o.object_id
where o.type in ('P', 'X')
      and schema_name(o.schema_id) = 'dbo'  -- put schema name here
      and o.name = 'uspPrintError'  -- put procedure name here
order by [object];

Columns

  • procedure - provided procedure schema name and name
  • ref - string 'is used by'
  • object - name of object with schema name which use specific procedure
  • object_type - type of found object

Rows

  • One row represents one object
  • Scope of rows: all objects that are using provided procedure
  • Ordered by object schema name and name

Sample Results

List of objects that are using dbo.uspPrintError procedure in AdventureWorks2017 database.