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.
| Author |
Topic |
|
MrBaseball34
Starting Member
2 Posts |
Posted - 2005-11-04 : 16:29:41
|
How would I modify this to get all SP's and iterate through them and return a list of SP names that contain a certain search term?CREATE proc spgetSPText(@sp_name sysname) asSET NOCOUNT ONdeclare C1 cursor for SELECT sc.text FROM sysobjects so INNER JOIN syscomments sc ON so.id = sc.id WHERE so.xtype = 'P' ORDER BY sc.coliddeclare @sp_line nvarchar(4000), @ptr varbinary(16)select cast(N'' as ntext) as sp_text into #tempselect @ptr = textptr(sp_text) from #tempopen C1fetch C1 into @sp_linewhile @@fetch_status = 0begin updatetext #temp.sp_text @ptr null 0 @sp_line fetch C1 into @sp_lineendclose C1deallocate C1select sp_text from #tempGO |
|
|
MrBaseball34
Starting Member
2 Posts |
Posted - 2005-11-04 : 17:21:02
|
Nevermind, someone from the NG's replied and I got it to work:create proc spgetSPText(@chvSearchtext varchar(50)) asSET NOCOUNT ON SELECT DISTINCT so.name into #temp FROM sysobjects so INNER JOIN syscomments sc ON so.id = sc.id WHERE ( so.xtype = 'TR' or so.xtype = 'FN' or so.xtype = 'P' or so.xtype = 'X' or so.xtype = 'TF' ) and sc.text like'%' + @chvSearchtext + '%' ORDER BY name select name from #tempdrop table #tempSET NOCOUNT OffGOexec spgetSPText 'sales'DROP PROCEDURE spgetSPText |
 |
|
|
|
|
|