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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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:

Try like this:

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

Open in new window

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

Open in new window

WHERE (type = 'P')
Éric MoreauSenior .Net ConsultantCommented:
Scott PletcherSenior DBACommented:
    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
    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

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.
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.