Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Replication (2008)
 Primary Key Violation

Author  Topic 

raguyazhin
Posting Yak Master

105 Posts

Posted - 2011-04-20 : 01:38:39

This is my one of the interview Question.

In Transactional Replication Primary Key Violation Error Occurred. How to Resolve it ?


Answer

If we Know the Violated Record in subscriber database table then delete the Record in Subscriber Table.
else truncate the Subscriber table and export the rest of rows from publisher database table.

Answer is Correct Or Wrong.


--
Ragu

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2011-04-20 : 08:15:35
If you just want to resolve it, you can delete the records in the subscriber and rerun the agents.. no need to truncate the entire table for a few records (if that is the case).
If you need to figure out the root cause, check if deferred updates is on.. check if you have users updating data on the subscriber, have a server side trace up to identify the root cause.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

raguyazhin
Posting Yak Master

105 Posts

Posted - 2011-04-21 : 01:13:17
quote:
Originally posted by dinakar

If you just want to resolve it, you can delete the records in the subscriber and rerun the agents.. no need to truncate the entire table for a few records (if that is the case).
If you need to figure out the root cause, check if deferred updates is on.. check if you have users updating data on the subscriber, have a server side trace up to identify the root cause.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/



Thanks for your reply.
How to on the deferred update? what is the use of this?


--
Ragu
Go to Top of Page

Jahanzaib
Posting Yak Master

115 Posts

Posted - 2011-04-24 : 05:46:35
Check this website for deferred upate
http://support.microsoft.com/kb/238254/EN-US

Deferred is same as mentioned Dinakar but the difference is Deferred update perform by as a process of Replication and we do the same go to subscriber then delete that particular record and then execute the agent to insert new and no available records or we can say also sync the subscriber to publisher

Deferred Update pass the Delete/Insert statement

Regards,

Syed Jahanzaib Bin Hassan
MCTS,MCITP,OCA,OCP,OCE,SCJP,IBMCDBA

My Blog
www.aureus-salah.com
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-04-27 : 20:44:19
quote:
Originally posted by dinakar

If you just want to resolve it, you can delete the records in the subscriber and rerun the agents.. no need to truncate the entire table for a few records (if that is the case).
If you need to figure out the root cause, check if deferred updates is on.. check if you have users updating data on the subscriber, have a server side trace up to identify the root cause.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/



First of all, PK violations at the subscribers are almost always due to the POOR practice of allowing writes at the subscriber(s) -- and usually against tables with identity columns.

But the reason I quoted Dinkar here, is that if you re-synch, there's no need to delete anything at the subscriber(s). The The snapshot will delete everything for you (under default settings).

I love interview questions like this. I would start with "Why are your developers writing to the subscribers?" Sure, I can fix it for you, but if we're going to make this go away..."
Go to Top of Page
   

- Advertisement -