Export SQL Agent jobs with steps and scripts using SQL Command

Use the below SQL command to list all SQL server jobs

USE [msdb]
   select 
    spider.name,
    steps.step_id,
    steps.step_name,
    steps.command
from MSDB.dbo.SysJobs spider
    inner join MSDB.dbo.SysJobSteps steps on steps.Job_Id = spider.Job_Id
where spider.enabled = 1
order by 1, 2

If you need to view the name use the below command

USE [msdb]

SELECT 
    spider.Name
    FROM dbo.sysjobs spider

Comments