Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 where is my proc

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-03-05 : 11:43:40
Greetings

Given a certain stored procedure name, how can I find out which database it is in?

Thank you!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-05 : 12:28:01
[code]EXEC sp_Msforeachdb 'IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME =''your procedure name'' AND ROUTINE_TYPE=''PROCEDURE'') SELECT ''?'''[/code]
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-03-05 : 14:49:09
are you sure you do not have BOL embedded in your cerebellum? Awesome!

Thank you very much
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-03-06 : 03:08:35
That should be

EXEC sp_Msforeachdb 'IF EXISTS (SELECT 1 FROM ?.INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME =''your procedure name'' AND ROUTINE_TYPE=''PROCEDURE'') SELECT ''?'''

Otherwise it would return all db names even if the procedure exists in a single db


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -