Look for Succeeded. You might also want to query select * from
"stephanie" <stephanie@discussions.microsoft.com> wrote in message
news:58B4FB85-9AF8-428F-8609-A789E86CA1AD@microsoft.com...
> How to show the agent was stopped??
> I found the stopped agents have status
> Idle,Idle, In progress
> started, Idle,Idle, In progress
>
>
>
>
> "Hilary Cotter" wrote:
>
>> They all mean the log reader agent is running, starting means its
>> starting,
>> in progress means it is reading transactions in the log, idle means there
>> is
>> nothing in the log reader to read.
>>
>> --
>> Hilary Cotter
>> Director of Text Mining and Database Strategy
>> RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
>>
>> This posting is my own and doesn't necessarily represent RelevantNoise's
>> positions, strategies or opinions.
>>
>> Looking for a SQL Server replication book?
>>
http://www.nwsu.com/0974973602.html >>
>> Looking for a FAQ on Indexing Services/SQL FTS
>>
http://www.indexserverfaq.com >>
>>
>>
>> "stephanie" <stephanie@discussions.microsoft.com> wrote in message
>> news:D0195B13-A1ED-47C8-833B-ACD39C4CF241@microsoft.com...
>> >I have tried the query in test env. I found an log agent are shown in
>> > different pattern
>> > Running Agent1: started, idle
>> > Running Agent2: idle
>> > Stopped agent1: Idle,Idle, In progress
>> > Stopped agent2: started, Idle,Idle, In progress
>> >
>> >
>> > Is there any standard pattern in the query which showing the job in
>> > running?
>> > Thanks in advance
>> >
>> > "Hilary Cotter" wrote:
>> >
>> >> You're right Stephanie
>> >>
>> >> This seems to only have non null values for the merge agent and then I
>> >> only
>> >> see if with a value of null or 0, even when my merge agent is running.
>> >> I
>> >> think you should query the job status in msdb.
>> >>
>> >> use msdb
>> >> select sysjobs.name,sysjobs.job_id,rundate, runtime ,case when
>> >> run_status
>> >> =1
>> >> then 'Started'
>> >> when run_status =2 then 'Succeeded'
>> >> when run_status =3 then 'In progress'
>> >> when run_status =4 then 'Idle'
>> >> when run_status =5 then 'Retrying'
>> >> when run_status =6 then 'Failed'
>> >> else 'unknown' end
>> >> from sysjobs join sysjobsteps
>> >> on sysjobsteps.job_id= sysjobs.job_id and sysjobsteps.command like
>> >> 'sp_msadd_logreader%'
>> >> join (select
>> >> sysjobhistory.job_id,runtime=max(run_time),rundate=max(k.rundate) from
>> >> sysjobhistory
>> >> join
>> >> (select sysjobhistory.job_id, rundate=max(run_date)from sysjobhistory
>> >> group by job_id ) as k
>> >> on k.job_id=sysjobhistory.job_id and k.rundate=sysjobhistory.run_date
>> >>
>> >> group by sysjobhistory.job_id) as l
>> >> on l.job_id=sysjobs.job_id
>> >> join sysjobhistory on sysjobhistory.job_id=sysjobs.job_id
>> >> and sysjobhistory.Run_date=l.rundate
>> >> and sysjobhistory.Run_time=l.runtime
>> >>
>> >>
>> >> --
>> >> Hilary Cotter
>> >> Director of Text Mining and Database Strategy
>> >> RelevantNOISE.Com - Dedicated to mining blogs for business
>> >> intelligence.
>> >>
>> >> This posting is my own and doesn't necessarily represent
>> >> RelevantNoise's
>> >> positions, strategies or opinions.
>> >>
>> >> Looking for a SQL Server replication book?
>> >>
http://www.nwsu.com/0974973602.html >> >>
>> >> Looking for a FAQ on Indexing Services/SQL FTS
>> >>
http://www.indexserverfaq.com >> >>
>> >>
>> >>
>> >> "stephanie" <stephanie@discussions.microsoft.com> wrote in message
>> >> news:554D6F3B-E265-412A-BE8B-F98BFA919ABF@microsoft.com...
>> >> > Hi all,
>> >> > I want to create a agent job to monitor the log agent and
>> >> > distribution
>> >> > agent
>> >> > regularly and I found system table msreplication_monitordata.
>> >> > According
>> >> > to
>> >> > BOL, it contains 'isagentrunningnow' which indicates the agent
>> >> > status.
>> >> > However, the field 'isagentrunningnow' is all 'NULL' in my server.
>> >> > Please
>> >> > advise. Thanks in advance
>> >>
>> >>
>> >>
>>
>>
>>