SQL Server Transaction Replication - Primary Key

Asked

Viewed 58 times

0

I have an environment with 2 branches, each branch has to have an application server with an SQL SERVER installed, I have configured the transaction Replication which is working perfectly, but if 2 people in different branches are entering data in the same table at the same time I get the primary key error violated.

I would like a configuration suggestion for this environment, I really need to keep a server in each branch for the application to get fast.

Thank you!

  • 1

    I think making lock table solves http://stackoverflow.com/a/23759307/3130590

1 answer

1

Assuming you are using an Identity as key.

My solution for you is to create a column (if it doesn’t exist) that indicates which branch is saving data and change its table so that this column is also part of your key.

Another solution, but it only serves if it applies to your current environment with 2 branches would be to recreate the Identity’s in the tables so that one affiliate would only have even id’s and the other only odd id’s.

But I do not indicate this second option, for N reasons.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.