Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Querying/Finding Stored Procedures

Author  Topic 

hismightiness
Posting Yak Master

164 Posts

Posted - 2008-07-28 : 14:51:34
I know that there is a place that allows you to look at the text of Stored Procedures. However, I have two problems I need to solve.

First, where is the Stored Procedure text stored?

Second, how do I query that location to let me find specific Stored Procedures? For instance, maybe I want to find all Stored Procedures that have a specific table name in them. How can this be accomplished?

- - - -
- Will -
- - - -
http://www.strohlsitedesign.com
http://blog.strohlsitedesign.com/
http://skins.strohlsitedesign.com/

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-28 : 14:58:35
1. syscomments (earlier versions)/sys.sql_modules (2005)
2. Search code - http://vyaskn.tripod.com/code/search_stored_procedure_code.txt

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 2008-07-28 : 15:09:37
If you want to look in just the stored procedures in a particular DB I usually run

select * from information_schema.routines where routine_definition like '%string I am looking for%'

But the SP that Tara linked to is pretty nice.

Thanks Tara.



An infinite universe is the ultimate cartesian product.
Go to Top of Page

hismightiness
Posting Yak Master

164 Posts

Posted - 2008-07-28 : 15:25:08
Perfect, Tara. Thanks a ton!

I was just experimenting with something I finally found:
http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/

- - - -
- Will -
- - - -
http://www.strohlsitedesign.com
http://blog.strohlsitedesign.com/
http://skins.strohlsitedesign.com/
Go to Top of Page
   

- Advertisement -