6

Is there any way to search and find ,what job holds a particular table refresh . There are multiple sql agent jobs with multiple steps.What is the sql query to search all jobs and locate the job name and steps?

This is to identify the steps associated with a table load

user1254579
  • 3,901
  • 21
  • 65
  • 104
  • https://serverfault.com/questions/14524/get-a-list-of-sql-server-agent-jobs – DhruvJoshi May 31 '18 at 10:50
  • Possible duplicate of [How to find all SQL Agent Jobs that call a given stored-proc](https://stackoverflow.com/questions/18105547/how-to-find-all-sql-agent-jobs-that-call-a-given-stored-proc) – EzLo May 31 '18 at 10:53

1 Answers1

12

Take a look at this:

Querying SQL Agent Jobs

use msdb

SELECT 
    [sJOB].[job_id] AS [JobID]
    , [sJOB].[name] AS [JobName]
    ,step.step_name
    ,step.command
FROM
    [msdb].[dbo].[sysjobs] AS [sJOB]
    LEFT JOIN [msdb].dbo.sysjobsteps step ON sJOB.job_id = step.job_id

WHERE step.command LIKE '%MYTABLENAME%'
ORDER BY [JobName]
B3S
  • 1,021
  • 7
  • 18