Searching Stored Procs

  • Does anyone know a way off to seach through all databases on a SQL 2000 server looking for a particular stored proc by name?

  • You can use the store procedure: sp_msforeachdb to run the query against every database on the system.

    http://www.mssqlcity.com/FAQ/Devel/sp_msforeachdb.htm

  • Thank you, that get's me much closer.  Now I just have to find a way to isolate the stored proc that SQL Profiler is listing.  Thanks again.

  • You should be able to use the DBid column in Profiler to determine which database the stored procedure is comming from. 

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Yep, but I'm a n00b and still trying to work out how to do that.

  • Well, when you set up your trace, make sure that the DatabaseID column is listed in the 'Data Columns' tab on the Trace Properties.  You can then cross reference this DBID with the following:

    SELECT dbid, Name

    FROM master..sysdatabases

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Thanks John, you have opened the eyes of the n00b!

  • James

    I take your original question as meaning that you're looking for the existence of the stored procedure, rather than its use.  If that's the case you don't need a Profiler trace.  Just run this query against each database, using sp_MSforeachdb if you like:

    SELECT ROUTINE_CATALOG + '.' + ROUTINE_SCHEMA + '.' + ROUTINE_NAME

    FROM INFORMATION_SCHEMA.ROUTINES

    WHERE ROUTINE_TYPE = 'PROCEDURE'

    John

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply