Sync between two sql database using change tracking. RRS feed

  • Question

  • I am trying to sync between Sql server 2008 Express edition as client and Sql server 2008 as server using SQL Server change tracking feature. I am using DbServerSyncProvider and SqlExpressClientSyncProvider (taken from the below link).


    This example uses its own change tracking concept for synchronization. I am trying to use internal change tracking of sql server, but I am stuck on definition of some functions like GetTableReceivedAnchor, GetTableSentAnchor, SetTableReceivedAnchor ... Can somebody please give me an example for this or provide me some hint to define these functions for internal change tracking.


    Tuesday, April 13, 2010 10:14 AM

All replies

  • afaik, you shouldnt have to change them. 

    The SQL Change tracking, it's just for retreiving the what was added/updated/deleted from the tables you're synching but it doesnt track what was sent and received.

    The anchor functions are for saving  in the anchor table what was sent and what was received for each table.

    To use SQL Change tracking, you just have to update your SelectIncremental queries as well as the commands for applying Insert/Update/Delete.


    Tuesday, April 13, 2010 10:29 AM
  • June, Here I am using custom client sync provider i.e SqlExpressClientSyncProvider which inherits from ClientSyncProvider, and it is a generic implementation of ServerSyncProvider. So, we need to override these functions to get and set anchors. If I leave it blank it doesn't synchronize the databases.

    Do we have a concept of anchors in SQL Change Tracking, in db synch server provider we are using SelectNewAnchorCommand and assigning it to "Select @sync_new_received_anchor = CHANGE_TRACKING_CURRENT_VERSION()" So, I am assuming we have some anchors which we are sending and receiving, if it not the case how would we define these anchor functions here for change tracking.

    Tuesday, April 13, 2010 12:07 PM
  • doesnt the SQLExpressClientSyncProvider sample include the implementation for the anchor functions?

    or are you creating a new clientsyncprovider? if you are, you just copy the same anchor method implementations from the SQLExpressClientSyncProvider.

    Again, SQL Change tracking tells you what has changed but not what was sent/received. So the anchor table is still required to keep track of sent/received. The anchor is not for change tracking, they're there to record watermark timestamps for what was uploaded (sent) and what was downloaded(received).

    The anchor table is only required on the client side and the setting of the anchor values is no different than a custom change tracking (non-SQL Change Tracking).


    Tuesday, April 13, 2010 12:29 PM
  •  Hi JuneT,

    Thanks for your help. I need to use change tracking on both sides. I want to use SQLExpressClientSyncProvider with Sql server change tracking and not the custom one. Any suggestions ? i see that Garry English (http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/c5fa0972-597a-458b-a6bb-1c5a2ed6188c/#e53828cf-ad56-4bdf-8b44-ff82bbba8efb ) has done it alreaedy.

    • Proposed as answer by ravindra bg Tuesday, April 13, 2010 6:33 PM
    Tuesday, April 13, 2010 1:06 PM
  • Sorry, wrong click above

    i too have the same question, searched all over the net didn't find much.. Please help

    Tuesday, April 13, 2010 6:35 PM
  • Sorry, wrong click above

    i too have the same question, searched all over the net didn't find much.. Please help

    Tuesday, April 13, 2010 6:35 PM
  • Hi ptdouglous,

    You can use SQL change tracking on both sides. And you can use SQLExpressClientSyncProvider  on the client side.

    What you need to do is just change the SelectIncremental commands to use SQL change tracking, change the Insert/Update/Delete commands for applying changes and SelectNewAnchorCommand.

    see http://msdn.microsoft.com/en-us/library/cc305322.aspx on how to write the commands.


    Tuesday, April 13, 2010 9:35 PM