I have 40 + databases, and I want to find procedures in all databases that use the text sp_reset_data
. This query helped me a lot:
DECLARE @Search varchar(255)
SET @Search='sp_reset_data'
SELECT DISTINCT
o.name AS Object_Name,o.type_desc
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.object_id
WHERE m.definition Like '%'+@Search+'%'
ORDER BY 2,1
But, this get the procedures only for the current database. Is there a way to improve this kind of query to look in every server's DB without manually changing the current DB?