| 437-991-3573 | Data Engineering Services
Resources Tools Services
Experts in Microsoft SQL Server on Windows, Linux, Containers | Clusters, Always On, FCI | Migrations, Cloud, Performance

Find a stored procedure call within a SQL Server Job
by BF (Principal Consultant; Architecture; Engineering)


--Returns 1 record from MSDB SYSJOBS table while many records with a stored procedure name can exist in SYSJOBSSTEPS table
--Use this if care only about the job name and not how many times the stored procedure is executed in different job steps

FROM msdb.dbo.sysjobs AS t1
FROM msdb.dbo.sysjobsteps AS t2
WHERE t2.job_id = t1.job_id
AND t2.command LIKE '%%'


--Returns a record for each instance of a stored procedure name existing in SYSJOBSSTEPS table
--Use this if care about each separate job step the stored procedure is called in

SELECT, t2.step_id, t2.command
FROM MSDB.dbo.sysjobs as t1
INNER JOIN MSDB.dbo.sysjobsteps t2 on t1.job_id=t2.job_id
WHERE t2.command like '%%'