I often need to search for some texts in the body of stored procedures. This query can help:
SELECT routine_name, routine_definition
FROM information_schema.routines
WHERE UPPER(routine_definition) LIKE UPPER('%texttobesearched%')
AND routine_type='procedure'
EDIT: just discovered that this method has some problems with long stored procedures; found another one that works better:
declare @searchString varchar(100)
Set @searchString = '%' + 'text to be searched' + '%'
SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
AND SO.Type = 'P'
AND SC.Text LIKE @searchString
ORDER BY SO.Name










5 comments:
I searched for something completely different, but found your website! And have to say thanks. Nice read. Will come back.
I am so glad that I took the time to look at this blog, because let me tell you. Not a lot of people know how to balance knowledge of a subject and content.
Hi. I wanted to thank you for the excellent info you have posted on your web site. I will definitely come back to check it out once more and have subscribed to your post. Have a great day.
I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post
I am glad to talk with you and you give me great help! Thanks for that, I am wonderring if i can contact you via email when i meet problems..
Post a Comment