/ Published in: SQL
Search SQL Server field names and stored procedure text, based on a keyword.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
-- 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