Search specific Stored Procedure in all Databases

EXEC sp_msforeachdb 'USE ?; IF EXISTS(SELECT 1 FROM [?].sys.objects WHERE name=''<<SP NAME>>'') PRINT DB_NAME() '

-- Example:
EXEC sp_msforeachdb 'USE ?; IF EXISTS(SELECT 1 FROM [?].sys.objects WHERE name=''usp_CommentTree'') PRINT DB_NAME() '

Write a Comment

Comment

0 Comments