To search every stored procedure in every database on every server (ranging from SQL Server 2005 to SQL Server 2016) for the string ‘QueryTraceOn’, I first registered every server within SSMS.
Right-clicking on the registered server folder, I chose ‘new query’ and ran ‘select 1’ to exclude from my list any server with issues.
Once I had an error free list, I ran this code (which took around 40 minutes) …
-- SearchProcs4String.sql EXEC sp_MSforeachdb 'use ? SELECT db_name() [Database], ROUTINE_SCHEMA + ''.'' + ROUTINE_NAME [Proc] FROM INFORMATION_SCHEMA.ROUTINES WITH (NOLOCK) WHERE ROUTINE_DEFINITION LIKE ''%QUERYTRACEON%'';'