Friday, March 23, 2012

Merge Replication Status

Hoping someone can help.
What merge system table/s will give me the current status of my merge agent
i.e. the Replication Monitor window in Enterprise Manager displays a status
of 'suceeded' etc etc - where can I source this field from within the
Replication System tables?
Any help appreciated.
this script will get you details of the last history for
the merge agent called 'DH1791628-Northwind-
NorthwindStaff-DH1791628-3'.
It will have basic error info if an error occurs.
If you want the detailed error info, you'll need to join
to the MSrepl_errors table: MSmerge_history.error_id =
MSrepl_errors.id. This table typically has several rows
so you might want to use a cursor to add the text
together.
HTH,
Paul Ibison (SQL Server MVP)
[vbcol=seagreen]
declare @.agent_id int
select @.agent_id = id from msmerge_agents where name
= 'DH1791628-Northwind-NorthwindStaff-DH1791628-3'
select top 1 case
when rh.runstatus = 1 then 'Start'
when rh.runstatus = 2 then 'Succeed'
when rh.runstatus = 3 then 'In progress'
when rh.runstatus = 4 then 'Idle'
when rh.runstatus = 5 then 'Retry'
when rh.runstatus = 6 then 'Fail'
end as RunStatus,
'start_time' = convert(nvarchar(12), start_time, 112) +
substring(convert(nvarchar(24), start_time, 121), 11, 13),
comments
from MSmerge_history rh
order by timestamp desc

No comments:

Post a Comment