Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-15
3
Medium Priority
?
362 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 2000 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

886 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