Friday, November 19, 2010

Find text inside all stored procedure for selected database

You might find this hady while you want to find particular text exists with in all the procedure inside database.

SELECT DISTINCT OBJECT_NAME(id) FROM syscomments WHERE [text] LIKE '%User%'

Above query will search 'User' text inside all the stored procedure and will return distinct stored procedure names.

Hope you find it useful.

Thanks,
Ashish Chotalia

1 comment:

  1. Just be aware that the syscomments table stores the values in 8000-character chunks, so if you are unlucky enough to have the text you're searching for split across one of these boundaries, you won't find it with this method.

    ReplyDelete