Hi.
I have setup an SQL Server 2005 Merge Replication.
Now I need to display the status of the replication programatically from the subscriber side, I have checked the documentation which mentions MergeSubscription & MergeSubscriberMonitor but I couldn't know how to use them!!
Any Help ?
Thanks
You can use "replication monitor"
on prompt execute: sqlmonitor.exe, then add your publishers.
http://technet.microsoft.com/en-us/library/ms152520.aspx
|||In order to display the status on the subscriber, you need to use the RMO components. Of course, I'm assuming that you are using a pull subscription configured such that the merge agent is running on the subscriber so that the data you need is already there. Alternatively, you could use something like the following, which I use to provide a macro level look at each susbscriber's last synch date. This table is added to the publication and replicated to all subscribers, so it can easily be pulled and displayed within an application. The proc is executed as a job on the publisher and assumes that the distributor is on the same machine as the publisher, you'll have to adjust if publisher and distributor are on separate machines.
CREATE TABLE dbo.ReplicationTimestamp(
SubscriberName varchar(50) NOT NULL,
LastReplicationDate datetime NULL,
LastEditDate datetime NOT NULL CONSTRAINT df_replicationtimestamp_editdate DEFAULT (getdate()),
LastEditUser varchar(30) NOT NULL CONSTRAINT df_replicationtimestamp_edituser DEFAULT (suser_sname()),
rowguid uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT df_replicationtimestamp_rowguid DEFAULT (newid()),
CONSTRAINT PK_ReplicationTimestamp PRIMARY KEY CLUSTERED (SubscriberName))
GO
CREATE PROCEDURE dbo.asp_UT_PopulateReplicationTimestamp
AS
UPDATE y
SET y.LastReplicationDate = z.LastSynch,
y.LastEditDate = getdate(),
y.LastEditUser = 'sa'
FROM ReplicationTimeStamp y inner join
(SELECT a.subscriber_name, MAX(b.time) lastsynch
FROM distribution.dbo.msmerge_agents a INNER JOIN distribution.dbo.msmerge_history b ON a.id = b.agent_id
WHERE (comments LIKE 'no data needed%'
OR comments LIKE 'upload%'
OR comments LIKE 'download%')
AND b.error_id = 0
GROUP BY a.subscriber_name, a.id, b.agent_id) z ON y.SubscriberName = replace(z.subscriber_name,'\SQLEXPRESS','')
No comments:
Post a Comment