February 28, 2007 at 1:05 pm
Does anyone know a way off to seach through all databases on a SQL 2000 server looking for a particular stored proc by name?
February 28, 2007 at 1:26 pm
You can use the store procedure: sp_msforeachdb to run the query against every database on the system.
February 28, 2007 at 1:39 pm
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.
February 28, 2007 at 1:45 pm
You should be able to use the DBid column in Profiler to determine which database the stored procedure is comming from.
February 28, 2007 at 1:51 pm
Yep, but I'm a n00b and still trying to work out how to do that.
February 28, 2007 at 2:01 pm
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
February 28, 2007 at 2:05 pm
Thanks John, you have opened the eyes of the n00b!
March 5, 2007 at 3:04 am
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