Solved

List all stored procedures that contain a specified table in T-SQL

Posted on 2013-01-15
3
342 Views
Last Modified: 2013-01-15
Hi Experts,
Working with a SQL Server 2008 R2 database that has hundreds of Stored Procedures (sprocs).

An employee built a table called mh_client. mh_client needs to be replaced as it is causing issues.

I would like to run a query that can list all the sprocs that contain mh_client so I can discuss the ramifications of these changes with the rest of the team.

Any advice?

John
0
Comment
Question by:JohnAeris
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 38777465
try this

select dISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%mh_client%'
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 500 total points
ID: 38777470
above will return all sp's views and functions

for only stopre procedures try this

select distinct so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%mh_client%'
and xtype='P'
0
 

Author Closing Comment

by:JohnAeris
ID: 38777643
Thank you!
Actually, the table appeared in views as well, which was not anticipated, so your first code was the most useful!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now