-1

Is there a way to search the SQL Server agent jobs, at the same time with a SQL query, for a specific table name?

Something like this:

Select top 100 *
from job_1
where definition like '%table_1%'

but instead of 1 job, it's all of the jobs?

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • That would depend on how you build and execute your job steps. Do you use t-sql directly in each job step? You might want to give a little more detail about your expected results - do you only want to know if the sql you are searching for is in a job, or other details? – Stu Jun 03 '21 at 21:46
  • Just wanted to search the jobs. – Chicken Sandwich No Pickles Jun 03 '21 at 22:06

1 Answers1

1

SQL Agent jobs are stored in the msdb database.

If I understand your intention, this should give you a start:

select j.name JobName, s.step_name StepName
from msdb.dbo.sysjobsteps s
join msdb.dbo.sysjobs j on j.job_id=s.job_id
where s.command like '%findme%'
Stu
  • 30,392
  • 6
  • 14
  • 33