I have an idea! Let's share some useful utility type stuff.
I'll start.
If you do this:
spcProcTextSearch 'update', 'tablename', 'fieldname'
It will return all my procs that update that specific field. Modify the where clause to your naming convention, I name all my procs, UDFs with spc or fnc because I'm retarded like that.
If you just wanted to know what procs ref a specific table or whatnot just this does it:
spcProcTextSearch 'table', null, null
I'll start.
If you do this:
spcProcTextSearch 'update', 'tablename', 'fieldname'
It will return all my procs that update that specific field. Modify the where clause to your naming convention, I name all my procs, UDFs with spc or fnc because I'm retarded like that.
If you just wanted to know what procs ref a specific table or whatnot just this does it:
spcProcTextSearch 'table', null, null
CREATE PROCEDURE spcProcTextSearch ( @Term1 varchar(100), @Term2 varchar(100), @Term3 varchar(100) ) AS SET @Term1 = '%' + @Term1 + '%' SET @Term2 = '%' + @Term2 + '%' SET @Term3 = '%' + @Term3 + '%' SELECT DISTINCT [name] as [proc], 'SP_HELPTEXT ' + [name] as HelpText FROM sysobjects LEFT JOIN syscomments ON syscomments.id = sysobjects.id WHERE ( [NAME] LIKE 'spc%' OR [NAME] LIKE 'fnc%' ) AND ( syscomments.[text] like @Term1 AND syscomments.[text] like ISNULL(@Term2, @Term1) AND syscomments.[text] like ISNULL(@Term3, @Term1) ) ORDER BY sysobjects.[Name]
