获取SQL Server代理作业的列表


55

我有很多可供选择的选项可添加到电子表格中,并且不希望手工操作。生成SQL Server代理作业列表的T-SQL命令是什么?

Answers:


65

在每台服务器上,您可以查询msdb中的sysjobs表。例如:

SELECT job_id, [name] FROM msdb.dbo.sysjobs;

谢谢,我想您就是击败我了,您将获得大奖!
alimack

19
-- List of all the jobs currently running on server
SELECT
     job.job_id,
     notify_level_email,
     name,
     enabled,
     description,
     step_name,
     command,
     server,
     database_name
FROM
    msdb.dbo.sysjobs job
INNER JOIN 
    msdb.dbo.sysjobsteps steps        
ON
    job.job_id = steps.job_id
WHERE
    job.enabled = 1 -- remove this if you wish to return all jobs

您可以格式化SQL吗?
Frank V

4

这是我的贡献-还获得类别名称并过滤出报表服务器作业。

SELECT  sysjobs.name 'Job Name',
        syscategories.name 'Category',
        CASE [description]
          WHEN 'No Description available.' THEN ''
          ELSE [description]
        END AS 'Description'
FROM    msdb.dbo.sysjobs
        INNER JOIN msdb.dbo.syscategories ON msdb.dbo.sysjobs.category_id = msdb.dbo.syscategories.category_id
WHERE   syscategories.name <> 'Report Server'
ORDER BY sysjobs.name 

2

我的老板实际上整理了我的要求-这给了我我想要的清单。

使用sysjobs中的msdb SELECT名称

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.