Find a stored procedure name with its content in SQL Server 2000

Kings picture Kings · Jan 10, 2013 · Viewed 50.4k times · Source

For a stored procedure, I have its full source code. But the name of that stored procedure has been lost. In this database, there are hundreds of stored procedures.

So is there a way by which I can find out the name of the stored procedure by using its contents or by using any of the variables in the contents?

This is puzzling me a lot. A help would be sincerley appreciated.

Answer

Melanie picture Melanie · Jan 10, 2013

Try this:

select * from sysobjects where id in 
(select id from syscomments where text like '%exec%')
order by [name]

where 'exec' is the text you're searching for. This query will search views also, just fyi