A fine site

SQL SERVER – Find Stored Procedure and View Related to Table in Database – Search in All Stored Procedure

Leave a comment

Following code will help to find all the Stored Procedures (SP) which are related to one or more specific tables. sp_help and sp_depends does not always return accurate results.

----Option 1
FROM syscomments sc
INNER JOIN sysobjects so ON
WHERE sc.TEXT LIKE '%tablename%'
----Option 2
FROM syscomments c
INNER JOIN sysobjects o ON
WHERE c.TEXT LIKE '%tablename%'

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.