Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 961
user1254579 Avatar asked May 31 '18 10:05

user1254579


People also ask

What are the steps to get a job in SQL Server?

To view job step information In Object Explorer, connect to an instance of the Microsoft SQL Server Database Engine, and then expand that instance.

How can get job name from job step ID in SQL Server?

You can use msdb. dbo. sysjobs to translate the job_id to a job_name.

How do I find SQL Server Agent jobs related to a database?

Using SQL Server Management StudioIn Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance. Expand SQL Server Agent, and then expand Jobs. Right-click a job, and then click Properties.

How do I get a list of references of a table in SQL Server?

Using SQL Server Management StudioIn Object Explorer, expand Databases, expand a database, and then expand Tables. Right-click a table, and then click View Dependencies.


1 Answers

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]
like image 83
B3S Avatar answered Nov 15 '22 04:11

B3S