记录一次sqlserver订阅与发布过程中的报错及解决过程

报错:

20598报错
20598报错主要还是由于两端数据库数据不一致导致,数据库在应用存储过程时产生了报错提示
记录一次Sqlserver数据库订阅与发布过程中的报错解决过程_第1张图片

应用复制的命令时在订阅服务器上找不到该行
错误消息
尝试的命令:

if @@trancount > 0 rollback tran

事务序列号:

--0x0000FDAB0003A908008F00000000 命令 ID: 7

错误消息:

应用复制的命令时在订阅服务器上找不到该行。 (源: MSSQLServer,错误号: 20598)

获取帮助: http://help/20598

应用复制的命令时在订阅服务器上找不到该行。 (源: MSSQLServer,错误号: 20598)

获取帮助: http://help/20598


在发布数据库上执行以下语句查看错误事务的id

use distribution
go
exec sp_helpsubscriptionerrors 'SSDTCEMANTEST','ssdt','skl_11_8','ANCHNET','ssdt';

use distribution
go
select * from
dbo.MSarticles m
where exists (select mc.article_id from MSrepl_commands mc where mc.xact_seqno=0x00011F4000009D42006B00000000 AND mc.article_id = m.article_id )

EXEC Sp_browsereplcmds
@xact_seqno_start='0x00011F4000009D42006B00000000',
@xact_seqno_end='0x00011F4000009D42006B00000000'

根据实际情况判断,要恢复数据还是跳过卡住的事务ID

---------------跳过订阅机器上面的错误------------------------
-----------------------在分发机器上--------------------------
--语法
exec sp_helpsubscriptionerrors [ @publisher = ]'publisher'
, [ @publisher_db = ]'publisher_db' 
, [ @publication = ]'publication' 
, [ @subscriber = ]'subscriber' 
, [ @subscriber_db = ]'subscriber_db'

--get publisher subscriber
select*from MSsubscriber_info

--get publisher_db publication subscriber_db=publisher_db
select*from MSpublications

--example
exec sp_helpsubscriptionerrors 'SQLw2k8','dbtranpub','dbtranpub_pub','SQLw2k8Subscriber','dbtransub'

--获取xact_seqno 值

----------------------在订阅机器上---------------------------
sp_setsubscriptionxactseqno [ @publisher= ]'publisher', 
[ @publisher_db= ]'publisher_db', 
[ @publication= ]'publication', 
[ @xact_seqno= ] xact_seqno

--example(忽略)
exec sp_helpsubscriptionerrors 'SQLw2k8','dbtranpub','dbtranpub_pub',xact_seqno;