List All SQL Agent Jobs in SQL Server

This post provides a SQL script to list all SQL Server Agent Jobs on a Microsoft SQL Server instance.

The sysjobs and sysjobsteps tables we are querying are in the M-S-D-B database. Fun fact, I am unable to publish a post with this actual database name without seeing a JSON error. I also get that error when trying to publish posts that mention Temp DB, it’s supposed to be one word, but I have to make it two words!

Hope this script is useful for you for showing all SQL Agent jobs.

List all SQL Agent jobs in SQL Server

As mentioned above we’re querying the M S D B database. The following script will return a list of all the SQL Agent jobs on the SQL Server host –

get sql agent jobs
script to get sql agent jobs

This SQL script returns a row for each job step contained within an Agent job, including information such as whether the job is enabled/disabled, and the TSQL command text for the job step.

If you want to return only Agent Jobs, not including Job Steps, you can query the sysjobs system table on its own (SELECT * dbo.sysjobs). Whenever you are querying SQL Server System Tables and you need more info, MS Docs is always the place to turn to, as linked above in this post.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *