<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://2pttechnology.com/web/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SQL Scripts</title><link>http://2pttechnology.com/web/forums/15/ShowForum.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>search for text in all your stored procedures</title><link>http://2pttechnology.com/web/forums/thread/181.aspx</link><pubDate>Thu, 05 Jun 2008 04:08:47 GMT</pubDate><guid isPermaLink="false">a285717b-1f26-4449-a706-ef28376a7378:181</guid><dc:creator>admin</dc:creator><slash:comments>0</slash:comments><comments>http://2pttechnology.com/web/forums/thread/181.aspx</comments><wfw:commentRss>http://2pttechnology.com/web/forums/commentrss.aspx?SectionID=15&amp;PostID=181</wfw:commentRss><description>&lt;P&gt;-- create temporary Result table to gather names and text&lt;BR&gt;-- of the procedures in the DataBaseName database :&lt;BR&gt;CREATE TABLE #Result&lt;BR&gt;(TextField varchar(max), ProcName varchar(100))&lt;/P&gt;
&lt;P&gt;-- create temporary ProcName table with the names of&lt;BR&gt;-- all the procedures in the database [DataBaseName]:&lt;BR&gt;CREATE TABLE #ProcList&lt;BR&gt;(ID int IDENTITY, ProcName varchar(100))&lt;/P&gt;
&lt;P&gt;-- populate the ProcName table with the procedure names:&lt;BR&gt;INSERT #ProcList SELECT [name] from sys.procedures&lt;/P&gt;
&lt;P&gt;-- get the number of procedures (to be used in the loop below):&lt;BR&gt;DECLARE @NumberOfProcs int&lt;BR&gt;SELECT @NumberOfProcs = COUNT(*) FROM sys.procedures&lt;/P&gt;
&lt;P&gt;–- loop to populate the Result table:&lt;BR&gt;DECLARE @i INT&lt;BR&gt;SET @i = 1&lt;BR&gt;DECLARE @ProcName varchar(100)&lt;BR&gt;DECLARE @SQL varchar(2000)&lt;BR&gt;WHILE @i &amp;lt;= @NumberOfProcs&lt;BR&gt;BEGIN&lt;BR&gt;SELECT @ProcName = ProcName FROM #ProcList WHERE ID = @i&lt;BR&gt;SET @SQL = ‘INSERT INTO #Result (TextField) EXEC sp_helptext ‘ + @ProcName&lt;BR&gt;EXEC (@SQL)&lt;BR&gt;UPDATE #Result SET ProcName = @ProcName WHERE ProcName IS NULL&lt;BR&gt;SET @i = @i + 1&lt;BR&gt;END&lt;/P&gt;
&lt;P&gt;-- look for a string you need [your string] in the Result table&lt;BR&gt;SELECT * FROM #Result WHERE TextField LIKE ‘%your string%’&lt;/P&gt;
&lt;P&gt;-- clean up&lt;BR&gt;DROP TABLE #Result&lt;BR&gt;DROP TABLE #ProcList&lt;/P&gt;</description></item></channel></rss>