Query to list the job names and step associated with a particular table
Asked Answered
I

1

9

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

Iain answered 31/5, 2018 at 10:37 Comment(2)
serverfault.com/questions/14524/…Oleograph
Possible duplicate of How to find all SQL Agent Jobs that call a given stored-procCarthy
T
15

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]
Teresaterese answered 31/5, 2018 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.