none
Newbie Question - Can I sync a table with a composite key, using only one column of the PK? RRS feed

  • Question

  • Hi,  I'm new to sync services.  Questions:

    Simple table definition: (identical schema on two servers):

    Name: MyTable

    Columns:

    [Id] BIGINT IDENTITY(1,1) NOT NULL,  --  << PK

    [GId] UNIQUEIDENTIFIER NOT NULL, 

    [Data] NVARCHAR(100) NULL

    Can I sync these tables on two servers, using GId as the unique identifier, letting each server have it's own value for the 'Id' column?

    If so, can I do this if GId is not part of the PK?  Or does it need to be part of a composite key?

    Any pointers to examples to get me started? 

    Thanks!


    WNC


    Edit: Anticipating responses:  The schema of the actual tables are in heavy use.  Changing PK's in the existing schema would be painful, if not impossible, given the code that is tied to the values in the schema.  I want to be able to add a GId to the tables that need to be synchronized, and synchronize based on that value, leaving the current PK out of the synchronization because it is an IDENTITY column. 
    • Edited by WineNCheese Friday, November 1, 2013 9:17 PM Clarification
    Friday, November 1, 2013 9:11 PM

Answers

All replies

  • I'm assuming this is not possible due to the complete lack of replies (or nobody reads this forum).  I've decided to make local copies of the tables to be synced with a different (unique) PK, and sync those tables between servers.  The local tables are kept in sync via triggers with MERGE statements.  Working so far.  Going to have to benchmark for performance once it is fully complete to determine if it is viable for production.

    WNC

    Monday, November 4, 2013 11:23 PM
  • that's should be possible, you can trick Sync Fx to thinking that another column is the PK.

    see: http://jtabadero.wordpress.com/2011/07/20/part-3-synchronizing-tables-where-client-and-server-primary-keys-are-different/

    • Marked as answer by WineNCheese Tuesday, November 5, 2013 6:19 PM
    Tuesday, November 5, 2013 5:00 AM
    Moderator
  • Thanks, that's almost exactly what I was looking for.  I need to "trick" both sides, but that looks promising.

    WNC

    Tuesday, November 5, 2013 6:21 PM