Primary Key Violation

  • Hi ,

    in my transactional replication my replication job failed with error of Primary Key Violation.

    what is steps need to resolve the issue.

  • did someone do Insert on replicated table on subscriber? i would say reinitialize subscription.

  • is there any options to do this

  • Have you got the transaction sequence number?

    You can browse SQL RELP CMDS and see what the row is that is trying to be inserted and either delete it from the subscriber, or remove it from the distributor.

    This means your replication design may not be servicing the business requirement correctly though and new rules put in place to prevent this in future... but you should be able to repair it without re-inializing.

    Try the following commands...

    use distribution

    go

    sp_browsereplcmds (goggle usage)

    -- get insert comand

    select * from MSrepl_commands

    where command_id = ?

    and article_id = ?

    and xact_seqno = ?

    -- remove command from the transaction list

    select *

    FROM MSrepl_transactions

    WHERE xact_seqno IN (SELECT xact_seqno

    FROM MSrepl_commands

    WHERE article_id = ?--Insert your Article_ID here

    --AND publisher_database_id IN () --Use if you have Multiple Publishers connected to One Distributor

    AND xact_seqno IN

    (

    ?

    )

    AND command_id = ? -- Use this if you would like to only remove specific command id

    )

    Good luck

  • I have an example of how to locate the transaction causing the problem here - http://sqlrambling.net/2014/10/31/replication-monitor-basic-overview/

Viewing 5 posts - 1 through 4 (of 4 total)

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