Users: 30k; Pages Per Session: 2.5p; Avg. Session Duration: 1:35mi
Explore Tools
{Featuring Microsoft Technologies + Enterprise Data + Cloud Computing}

Find a stored procedure call within a SQL Server Job
by BF (Senior MSSQL Operations - Enterprise, Cloud, Strategy)


--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 '%%'