Determine the current status of a SQL Server Agent job

Due to the problem that there is no definite table for getting information about the current status of jobs, I created a small procedure grabbing the information from parts of the internal procedures used to extract the very relevant information.

As an (optional) parameter you can specify a jobname you want to investigate (no value will loop through all jobs) and you will get a table back with the jobname and the state of the job.

-Jens

dbo.SpGetJobStatus.sql