Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-15
3
Medium Priority
?
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

688 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