MSSQLCity.Com - All about MS SQL
     
About Us  
SSWUG Articles  
Articles  
FAQ  
Administration  
Backup/Restore  
Connectivity  
Development  
General  
Installation  
OLAP  
Replication  
Transfer/move  
Trouble  
SQL 6.5  
Scripts  
Tips  
Test Exams  
Advertise  
Download  
History  
Search  
Traffic  
Related Links  
     
Your button logo
Add to Favorites
 
     
 


How do we handle duplicate primary keys for transaction/merge replication?

Answer:

If you use transaction replication then Log Reader Agent read transaction log and all transactions for replication will be transferred into distribution database as Insert, Update and Delete commands. So, if you try to insert the record with existing primary key you will receive duplicate primary key error and new record will not be inserted. How can you handle this? For transaction replication there is no way to handle this error. You should resync your databases or correct records manually, in this case. This error can be handled only in merge replication. Read about "Conflict Resolution", Title "Merge Replication" in SQL Server Books Online. It's therefrom:

When conflicts occur, the agent initiates an automatic reconciliation.
The "winner" of the conflict can be based on a user-specified priority
scheme, a "first wins" solution, or a custom resolution using COM
and stored procedures.

 

 
Visit The SQL Server Worldwide User's Group for all the latest news and information about SQL Server, Oracle, DB2 and XML for developers and administrators.

(c) 1997, 2005 Bits on the Wire, Inc