Solved

Which rows changed in merge replication?

Posted on 2013-10-31
4
811 Views
Last Modified: 2013-10-31
I am merge replicating between two SQL 2008 R2 servers.   These are hardly touched, yet when I did a synchronisation, I had loads of updates.

How can I find out which rows were changed?

Thanks,

  Colin
0
Comment
Question by:colinspurs
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Anuj earned 500 total points
Comment Utility
Merge replication tracks the dml changes by using Insert, update and delete triggers, these changes are tracked in tables MSMerge_tombstone (For Deletes) MSMerge_Contents (For Update and Inserte) and MSMerge_GenHistory  (Group of changes). Replicated tables has rowguid column, so when a row changes its rowguid is tracked in corresponding MSMerge_tombstone , MSMerge_Contents (depending on Delete\Insert\Update) and MSMerge_GenHistory tables.

Following query determine the changed rows and in which container they exists (In MSMerge_Contents)

select <YourTable>.*
from <YourTable>
inner join MSmerge_contents on tCustomers.rowguid = MSmerge_contents.rowguid
inner join MSmerge_genhistory on MSmerge_contents.generation = MSmerge_genhistory.generation


Below code finds the pending changes in merge replication.

select <YourTable>.*
from <YourTable>
inner join MSmerge_contents on tCustomers.rowguid = MSmerge_contents.rowguid
inner join MSmerge_genhistory on MSmerge_contents.generation = MSmerge_genhistory.generation
where MSmerge_genhistory.genstatus = 0
0
 
LVL 3

Author Comment

by:colinspurs
Comment Utility
That's very helpful, thanks.  How can I find which tables Tablenick refers to in MSmerge_contents?

Also, to find which database updated which (publisher or subscriber) I should run the queries on both databases?

Colin
0
 
LVL 15

Expert Comment

by:Anuj
Comment Utility
That you can get form sysmergearticles

SELECT nickname
FROM SysMergeArticles
0
 
LVL 3

Author Closing Comment

by:colinspurs
Comment Utility
Brilliant, thanks again. I found it really hard to get help on the web.

Cheers,

   Col
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now