Solved

Which rows changed in merge replication?

Posted on 2013-10-31
4
886 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HIghlights of SSIS? 3 45
when sa SQL Login becomes locked 6 34
SQL Query 20 25
Query Task 8 23
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.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

752 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