Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Quires or Scripts - Jobs Related

$
0
0

Hi Sql Techies,

Please Check and Correct My Quires:

1) Find Out What are Jobs Running Now

SELECT A.Name, A.job_ID, A.Originating_Server,

B.run_requested_Date,B.start_execution_date,B.stop_execution_date,b.next_scheduled_run_date,DATEDIFF(MINUTE, B.run_requested_Date,GETDATE()) AS JobRunning@InMins

FROM msdb.dbo.sysjobs_view A

innerjoin msdb.dbo.sysjobactivity B

ON (A.job_id= B.job_id)

WHERE run_Requested_dateisnot nullandstop_execution_dateisnull

2) Find out from how long a Specific Job is running:

SELECTDATEDIFF(Minute,A.start_execution_date,GetDate())ASJobRunning@InMins

FROMmsdb..sysjobactivityA

JOINmsdb..sysjobsBon B.job_id =A.job_id

WHEREA.stop_execution_dateISNULL

ANDA.start_execution_dateISNOT NULL

ANDB.name='Specify Your Job Name'

ANDNOTEXISTS( SELECT 1

    FROMmsdb..sysjobactivityC

    WHEREC.job_id=A.job_id

    andC.start_execution_date>A.start_execution_date

)

3) How to Join Results of Two Stored Procedures 


Viewing all articles
Browse latest Browse all 12963

Trending Articles