This post contains a SQL script that will return a list of 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. Interesting fact, I am unable to publish a post with this actual database name without seeing a JSON error.
When querying system tables in MS SQL Server, we should refer to Microsoft Docs as linked ^
MS Docs gives us a reference point for column definitions and the docs often include various example SQL code snippets.
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 –
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.