Solved

How do I determine SQL Agent jobs active?

Posted on 2002-06-19
2
994 Views
Last Modified: 2008-01-09
SQL 7 Agent runs enabled jobs, at their appropriate times (or on request).  At any moment in time from zero thru N jobs could currently be active.  I would like to be able to run a query which would provide me with the information on what jobs are currently running when I submit the query.  Following is a view I tried creating to give me the info, but it does not appear to work.  I can create a SQL Agent Job which simply does a "waitfor" for 60 seconds, start it manually, then run the below.  The running/active job is not detected by my query.


CREATE VIEW What_jobs_are_running
AS
SELECT top 30 name,
       case b.run_status
       when 0 then 'failed'
       when 1 then 'succeeded'
       when 2 then 'retry'
       when 3 then 'canceled'
       when 4 then 'in progress'
       end
       as 'run status',
       b.sql_severity as 'err severity',
       b.run_date as 'run date',
       b.step_name, b.server,
       b.message as 'error message'
FROM msdb..sysjobs a  inner join sysjobhistory b on a.job_id = b.job_id
WHERE name like '%' and b.run_status = 4
order by b.run_date desc, a.name asc

I am not asking for the above code to be debugged.

I simply want to know how to query to find out what SQL Agent jobs are running/active.

TIA


0
Comment
Question by:solart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
bronwyn_black earned 100 total points
ID: 7094458
Hi,

This should work:

sp_help_job NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1

where the last param:
-- 1 = Executing, 2 = Waiting For Thread, 3 = Between Retries, 4 = Idle, 5 = Suspended, 6 = [obsolete], 7 = PerformingCompletionActions

Regs,

BB.
0
 
LVL 1

Author Comment

by:solart
ID: 7096157
Verified that solution actually works.  Thanks.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question