Handling of Autoincrement key in replication???????

  • Hello Friends,

    Can any one tell me about how Autoincrement fields are handled in Replication. What I mean to say if suppose I have an autoincrement field in one of my table and subscribers add new record to their own replicas then while sysnchronization how will it be handled.

  • You have three options:

    1.  When you setup merge replication, you can have SQL Server allocate a "pool" of numbers to each subscriber.  For example, new records added at subscriber1 would start with number 100 up to 150, and new records added at subscriber2 would start with 151 up to 200, etc.

    2.  Don't use the identity property (autoincrement).

    2.  The other option is to ensure that all new records are added at the publisher. <G>

     

    -ws

  • This option will prevent replication conflicts:

    1. Start the identity on the publisher at an odd number and increment by 2

    Start the identity on the subscriber at an even number and increment by 2

    This prevents the numbers from ever catching each other; you won't have to use a range until you get to 8 machines.  If you have 4 machines then you may also need to set the addtional matchines to start at -1 by 2 and start at -2 by 2 respectively.  Once you get to 8 machines then you will need to start using ranges both with positive and negative seeds.

    Note: Ensure the "not for replication" option is set on the identity columns.  This will prevent the "reseeding" when the new records are merged at publisher/subscriber.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply