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 2000 Forums
 SQL Server Development (2000)
 Search for phrase within Stored Procedures

Author  Topic 

hmjesus
Starting Member

3 Posts

Posted - 2008-01-09 : 22:51:42
Just had a quick read through the forum, but couldn't find a thread relating to this so thought I'd start one.

Basically, the previous developer at my work had a script she ran to locate a specific phrase within a list of Stored Procedures (in SQL Server 2000). The script left with the developer.

Basically, does anyone know whereabouts in SQL Server 2000 I would pull from to run a query to locate a phrase within a stored procedure?

Thank you very much in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-09 : 23:20:01
You have a third party script which is freely available for download called sp_grep. Download it from net and run it in your db. It will take a string as param and returns list of stored procedures,triggers,etc. where this string is present. Hope thats exactly what you are looking for.
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-01-09 : 23:55:10
select o.name
from syscomments s
join sysobjects o on s.id=o.id
where text like '%searchstring%'


elsasoft.org
Go to Top of Page

hmjesus
Starting Member

3 Posts

Posted - 2008-01-10 : 00:06:12
quote:
Originally posted by jezemine

select o.name
from syscomments s
join sysobjects o on s.id=o.id
where text like '%searchstring%'


elsasoft.org


Thank you!

This was exactly what I was after.
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-01-10 : 01:20:30
note that if you have an object longer than 4000 chars, the text you are searching for could be split across different rows in syscomments, and then the query would not find your text.

more bulletproof is to script out the entire db and then search the scripts, but that takes more time obviously.

<plug>or use sqlspec and search the chm!</plug>


elsasoft.org
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-10 : 01:46:06
or use this to script out and search
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/12/13/script-out-procedures-and-functions-part-2.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -