Can anyone please advise on a way to retrieve a listing of all stored procedures along with their schema names in all database? Thanks for your input!
CREATE TABLE #x(db SYSNAME, s SYSNAME, p SYSNAME);
DECLARE @sql NVARCHAR(MAX) = N'';
SELECT @sql += N'INSERT #x SELECT ''' + name + ''',s.name, p.name
FROM ' + QUOTENAME(name) + '.sys.schemas AS s
INNER JOIN ' + QUOTENAME(name) + '.sys.procedures AS p
ON p.schema_id = s.schema_id;
' FROM sys.databases WHERE database_id > 4
EXEC sp_executesql @sql;
SELECT db,s,p FROM #x ORDER BY db,s,p;
DROP TABLE #x;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With