Labels

Friday, 7 February 2020

Find SQL Agent job name which is using specific stored procedure inside

DECLARE @proc AS VARCHAR(50)

SET @proc = 'usp_find_record' --specify stored procedure name here

SELECT job.name
 ,job.description
 ,step.job_id AS 'JobID'
 ,step.command AS 'Source'
FROM msdb.dbo.sysjobs job
INNER JOIN msdb.dbo.sysjobsteps step ON step.job_id = job.job_id
WHERE step.command LIKE '%' + @proc + '%'