If I want to query all databases on a server to see if a stored procedure is present, I can combine a sp_executesql and run a cursor over a query similar to the following:
SELECT
'select ' + '''' + name + '''' + ', name from [' + name
+ '].sys.procedures WHERE name = ''usp_MyProc'' COLLATE SQL_Latin1_General_CP1_CI_AI '
FROM sys.databases
-- I get a collation error from the following
WHERE name NOT IN ('ReportServer', 'ReportServerTempDb');
Can I do the same thing without dynamic sql and without the cursor?