Monday, April 16, 2012

Troubleshooting replication duplicate key error

-- Troubleshooting replication duplicate key error

-- Step 1

/* Get the transaction sequence number from the replication monitorfor example : Transaction sequence number: 0x00024D74000038DD000800000000*/

-- Step 2
/* Pass the transaction sequence number to the msrepl_commands table to the get the command id and publisher id */

use distribution
go

select * from msrepl_commands where xact_seqno=0x00024D74000038DD000800000000

/* Execute the sp_browsereplcmds stored procedure from the distribution database. This will give you the actual command that it is trying to execute and failing on the duplicate key error */

EXEC Distribution..sp_browsereplcmds @xact_seqno_start = '0x00024D74000038DD000800000000' ,@xact_seqno_end = '0x00024D74000038DD000800000000',@command_id =1 , @publisher_database_id = 1

-- Step 3
/*
Go to the subscriber database to see what this stored procedure is doing. -- Then usually delete the record from the subscriber and the replication will automatically synchronize the same record to the subscriber again
*/

No comments:

Post a Comment