How to find all SQL Agent Jobs that call a given stored-proc

前端 未结 3 1892
春和景丽
春和景丽 2020-12-28 15:49

I\'m in SQL 2008/R2. I want to run a query to see if there is a SQL Agent job calling a specified stored proc (there are too many to inspect manually).

3条回答
  •  醉话见心
    2020-12-28 16:36

    There's alternative to find all procedures called by all jobs inside a specific instance:

    SELECT jss.jobname, jss.step_name, p.name  FROM sys.procedures p 
    
    CROSS apply
    (
        SELECT j.name AS jobname, js.step_name FROM msdb.dbo.sysjobsteps js 
        INNER JOIN msdb.dbo.sysjobs j ON js.job_id=j.job_id
        WHERE js.command LIKE '%'+p.name+'%'
    ) jss
    

提交回复
热议问题