SQL Server
 
By Firoz AnsariMay 10, 20191 min readComments (0)
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() '

JOIN THE DISCUSSION
COMMENTS (0)
Copyright © 2021 Firoz Ansari.
All Rights Reserved.