how to search all stored procedures in a database for a particular string.

I have a database with about 200 stored procedures. If I have a table named "Customers". I need a sql query that will search all of my stored procedures for the name "Customers". Is there a sql someone can share with me that would perform such a search?
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mandeep SinghDatabase AdministratorCommented:
Hi,

Try like this:

SELECT OBJECT_NAME(object_id), OBJECT_DEFINITION(object_id)
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE '%customer%'

Open in new window

0
HuaMin ChenProblem resolverCommented:
Hi,
You can list out all the SP objects like
SELECT name, 
       type,
	   s.*
  FROM dbo.sysobjects s

Open in new window

WHERE (type = 'P')
0
Éric MoreauSenior .Net ConsultantCommented:
0
Scott PletcherSenior DBACommented:
SELECT
    OBJECT_NAME(sed.referencing_id) AS Referencing_Object,
    sed.referenced_entity_name AS Referenced_Object_Name,
    OBJECTPROPERTYEX(OBJECT_ID(sed.referenced_entity_name), 'BaseType') AS Referenced_Object_Type,
    sed.is_caller_dependent, sed.is_ambiguous
FROM sys.sql_expression_dependencies sed
WHERE
    sed.referenced_entity_name = 'Customers' AND --referenced object name is 'Customer'
    --OBJECTPROPERTYEX(OBJECT_ID(sed.referenced_entity_name), 'BaseType') = 'U' AND --referenced object is a user table
    OBJECTPROPERTYEX(sed.referencing_id, 'BaseType') = 'P' --referenced by a proc
ORDER BY Referenced_Object_Name, Referencing_Object, Referenced_Object_Type
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brgdotnetcontractorAuthor Commented:
Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.