Return to Snippet

Revision: 37608
at December 14, 2010 00:13 by axs221


Initial Code
-- Search Table Field Names
select a.name, b.name
from syscolumns a
      inner join sysobjects b on a.id = b.id
where LEFT(b.name,3) IN ('tbl','sys')
	AND a.name LIKE '%KEYWORD%'
order by b.name


-- Search Stored Procedure Text
SELECT sys.sysobjects.name, sys.syscomments.text
FROM sys.sysobjects INNER JOIN syscomments 
ON sys.sysobjects.id = sys.syscomments.id
WHERE sys.syscomments.text LIKE '%KEYWORD%' 
AND sys.sysobjects.type = 'P'
ORDER BY sys.sysobjects.NAME


-- OR this alternative:
SELECT ROUTINE_NAME, ROUTINE_DEFINITION 
FROM INFORMATION_SCHEMA.ROUTINES 
WHERE ROUTINE_DEFINITION LIKE '%prSendCdoSysMail%' 
AND ROUTINE_TYPE='PROCEDURE'
ORDER BY ROUTINE_NAME

Initial URL

                                

Initial Description
Search SQL Server field names and stored procedure text, based on a keyword.

Initial Title
Search SQL Server field names and stored procedure text

Initial Tags
sql, search, server

Initial Language
SQL