Hi ,
There are multiple jobs on my SQL Server and I want to list the jobs.
1: When i execute 'exec msdb..sp_help_job ' I get 64 jobs listed
2: When i execute below query, I get 66 jobs listed
Select j1.ins_id max_ins_id,job.job_id,min_ins_id,j1.run_duration
,j1.run_status, job.category_id,j2.sql_message_id,ja.strt_exec_date From
msdb..sysjobs job with (NOLOCK) Left JOIN (Select
ins_id,a.job_id,min_ins_id,a.run_duration,a.run_status From
msdb.dbo.sysjobhistory a with (NOLOCK) INNER JOIN (Select
max(a.instance_id)ins_id,min(a.instance_id) min_ins_id,a.job_id From
msdb.dbo.sysjobhistory a with (NOLOCK),msdb.dbo.sysjobhistory b with
(NOLOCK) where a.job_id = b.job_id Group by a.job_id)a1 on a1.ins_id=
a.instance_id)j1 ON job.job_id=j1.job_id Left JOIN
msdb.dbo.sysjobhistory j2 on min_ins_id=j2.instance_id Left JOIN (select
job_id,max(start_execution_date) as strt_exec_date from
msdb..sysjobactivity with (NOLOCK) group by job_id) as ja on
job.job_id=ja.job_id
I would like to know the reason for this that why such inconsistency is seen and the reason for filtering.
Which attribute or table is casuing this?
Thanks.