Use database
DECLARE @ProcName varchar (50)
Create Table #tmpName (Content varchar (2000))
Create Table #tmp (procname varchar, Content1 varchar (8000))
--Define a cursor
DECLARE Searchproc CURSOR for
--Query the name of the stored procedure in the database, as far as possible to remove the system proc, can be based on the Crdate time field to find non-system proc
Select name from sysobjects where type= ' P ' and name is not a like ' dt_% '
OPEN Searchproc
FETCH NEXT from Searchproc
Into @ProcName
While @ @FETCH_STATUS >=0
BEGIN
Print @ProcName
Insert into #tmpName (Content) Exec sp_helptext @ProcName
Insert into #tmp (procname,content1) Select @ProcName #tmpName the. Content from #tmpName
--Empty the temp table when you're done filling it up
Truncate Table #tmpName
FETCH NEXT from Searchproc
Into @ProcName
END
CLOSE Searchproc
Deallocate Searchproc
GO
Select ProcName from #tmp where Content1 like '% find content% ' GROUP by procname
Select Procname,content1 from #tmp where Content1 like '% find content% '
Select Procname,content1 from #tmp where procname= ' stored procedure name '
--Delete temporary tables
Drop Table #tmpName
Drop Table #tmp
Use SQL statements to find what is contained in all stored procedures in a database (GO)