How find string in SQL agent jobs

Product:
Microsoft SQL server 2016

Issue:
Try to find if any SQL agent jobs have reference to file foo.

Solution:

Run this SQL query on the server:

SELECT s.step_id as 'Step ID',
j.[name] as 'SQL Agent Job Name',
s.database_name as 'DB Name',
s.command as 'Command'
FROM msdb.dbo.sysjobsteps AS s
INNER JOIN msdb.dbo.sysjobs AS j ON s.job_id = j.job_id
WHERE s.command LIKE '%foo%'

 

More Information:

https://www.sqlserver-dba.com/2020/05/how-to-search-sql-server-agent-command-text-for-a-string.html