--SELECT * FROM [distribution].dbo.MSReplication_monitordata WHERE status not in(1,2,3,4)
SELECT * FROM [distribution].dbo.MSReplication_monitordata
where not( agent_type=1 and status=2)
and not(agent_type = 2 and status=3)
3--2 - error
/*
agent_type
1 = Snapshot Agent
2 = Log Reader Agent
3 = Distribution Agent
4 = Merge Agent
9 = Queue Reader Agent
status
1 = Started
2 = Succeeded
3 = In progress
4 = Idle
5 = Retrying
6 = Failed
*/
-- 1 = Snapshot Agent / 2 = Succeeded
SELECT * FROM [distribution].dbo.MSReplication_monitordata where agent_type=1 and status<>2
-- 2 = Log Reader Agent / 3 = In progress
SELECT * FROM [distribution].dbo.MSReplication_monitordata where agent_type=2 and status <>3
-- 3 = Distribution Agent / 3 = In progress, 4 = Idle
SELECT * FROM [distribution].dbo.MSReplication_monitordata where agent_type=3 and (status <>3 or status <>4)
SELECT count(1) FROM [distribution].dbo.MSReplication_monitordata
where
(agent_type=1 and status<>2)
or (agent_type=2 and status <>3)
or (agent_type=3 and (status <>3 and status <>4) )
SELECT * FROM [distribution].dbo.MSReplication_monitordata