I am required to generate a list of SQL Server scheduled jobs along with there associated steps. It would be compared to same list from another server where the jobs just have been transferred. Following code would provide me job names along with their steps
USE MSDB GO SELECT v.name AS JobName, step_name FROM sysjobs_view v inner join sysjobsteps t ON v.job_id = t.job_id ORDER BY v.name, step_name GO
We may add further properties of job or step from SYSJOBS_VIEW and SYSJOBSTEPS respectively.