GreggPeele
asked on
Find database that have a specific stored proc
I need a line of SQL that will return only the databases on my SQL Server instance that have a specific stored procedure defined. If the proc is named "sp_custom_proc", how would I enumerate all the databases where that proc is defined?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
CREATE TABLE #x(db varchar(30), obj SYSNAME);
EXEC sp_msforeachdb
@command1 ='INSERT #x SELECT ''?'',name
FROM ?.sys.procedures
WHERE name =''PX_ReleaseBOL37'';';
SELECT * FROM #x;
DROP TABLE #x;