Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
How to search through all store procedures and find all containing search term in SQL Server 2012 ?
Posted
Comments
RedDk 24-Apr-13 15:59pm    
My solution to this exact problem, if one could call anything that when they're introduced to "query", is make a database of all "CREATE PROCESS X" TSQL that they write. Now that I think of it, a TABLE in a database (ntext or nvarchar converted to XML single liners) will suffice. And then do the searching there.

hi,

Check this query,

select * from INFORMATION_SCHEMA.ROUTINES where ROUTINE_NAME like 'sp%'
 
Share this answer
 
Hi,

Check the following Code
SQL
SELECT DISTINCT OBJECT_NAME(C.ID) 
FROM syscomments C
INNER JOIN FROM sys.procedures P ON P.Name=OBJECT_NAME(C.ID)
WHERE C.Text LIKE '%Search_String%'
AND P.type = 'P'

Regards,
GVPRabu
 
Share this answer
 
v2
Comments
Sudhakar Shinde 24-Apr-13 6:47am    
You need to add WHERE condition to find out only stored procedures as mentioned in the requirement.
gvprabu 24-Apr-13 6:54am    
yes correct, We have to make JOIN with sys.procedures table or INFORMATION.SCHEMA.
Try using SSMS plugin ApexSQL Search[^] It is free and intuitive.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900