Solved

Which rows changed in merge replication?

Posted on 2013-10-31
4
908 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Anuj earned 500 total points
ID: 39613743
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
ID: 39613852
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
ID: 39613957
That you can get form sysmergearticles

SELECT nickname
FROM SysMergeArticles
0
 
LVL 3

Author Closing Comment

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

Cheers,

   Col
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

623 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