Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I would like to search text in stored procedure(Sqlserver2005).

I can do this with the following script.

SQL
SELECT name
FROM   sys.procedures
WHERE  Object_definition(object_id) LIKE '%Order%'


But, It is searching in commented lines also. I do not want to search commented lines of stored procedure.

Please help me!
Posted

Hi Prasad,

Check this below query it works for me and tested also.

SQL
SELECT name
FROM   sys.procedures
WHERE  Object_definition(object_id) LIKE '%Order%' and
 Object_definition(object_id) NOT LIKE '%/**%'



Let me know if it is not work...
 
Share this answer
 
Comments
Prasad Avunoori 9-Jul-14 5:56am    
No, Vani. It also didn't work for me.

Because it filters the stored procedures which have /*.
This link might lead to the solution :
Search Text in Stored Procedure in SQL Server
using escape
 
Share this answer
 
Comments
Prasad Avunoori 9-Jul-14 3:13am    
Thank you. But, i don't want to search commented text.
Try using the below query

SQL
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFOMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE ('%YOURSEARCHTEXT%')
 
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