Find All Stored Procedures Related a Table or a Database

This blog explains how to retrieve a list of all stored procedures related to tables or a database.

Query: 

  1. SELECT DISTINCT o.name AS StoredProcedure_Name  
  2.   
  3. FROM syscomments c  
  4.   
  5. INNER JOIN sysobjects o ON c.id=o.id  
  6.   
  7. WHERE xtype='P'  

Output:

 
 
List of all stored Procedure related to a table:
 
Query:

  1. SELECT DISTINCT o.name AS StoredProcedure_Name  
  2.   
  3. FROM syscomments c  
  4.   
  5. INNER JOIN sysobjects o ON c.id=o.id  
  6.   
  7. WHERE xtype='P' AND c.TEXT LIKE '%TblCompany_General_Info%'  

Output: 

 
Ebook Download
View all
Learn
View all