Professional Documents
Culture Documents
Once it is done.
o Delete one row of data from subscriber.
o Update the same row in publisher
Go to replication monitor to view the error:
Command attempted:
if @@trancount > 0 rollback tran
(Transaction sequence number: 0x00000015000001B9000400000000, Command ID: 1)
You can see that there are 2 items mentioned in error one is transaction sequence number:
0x00000015000001B9000400000000 and another is command id:1
System Procedure sp_browsereplcmds takes the values transaction sequence number and
command id as parameters and outputs the command that caused the errors.
Transaction sequence number:
Identifier for the transaction which contains commands.
Command ID:
Each command have a unique ID within the scope of the transaction sequence. The command starts at 1
and increment by 1 for each new command. Command should be updated in same sequence if it is more
than one command.
Get the article id and publisher database id from following query on distributor database
using,
select *
from msrepl_commands (nolock)
where command_id = 1 and xact_seqno = 0x00000015000001B9000400000000
[sp_MSupd_dboTestTable]
You can see from above statement that for ID 2 update statement is failed
Go to subscriber and insert the row for ID 2
INSERT INTO [xyz].[dbo].[TestTable]
([id]
,[text])
VALUES
(2
,'Anydata')
GO
If there are mutiple rows are missing then follow the below steps:
Create a temp table in the subscriber with same structure as the article(table being
replicated)
select * INTO TestTable_ReplIssue__1 FROM TestTable (nolock) where 1=0
Insert the rows into the temporary table by selecting the data from publisher using the
linked server.
INSERT INTO TestTable_ReplIssue__1
select * FROM [MININT-8JHDRAI].TestDB.dbo.TestTable
where ID between 4 and 6
Insert the missing rows into the article by comparing with the temp table created above.
BEGIN TRAN
INSERT INTO TestTable
SELECT A.* FROM
TestTable_ReplIssue__1 A (nolock)
Left Join TestTable (nolock)B On A.id = B.id
Where B.id Is null
COMMIT
If there is any problem with Linked server while inserting the records follow the steps below
select * from sys.servers
sp_dropserver 'MININT-8JHDRAI', 'droplogins';
EXEC sp_addlinkedserver
'MININT-8JHDRAI',
N'SQL Server'
GO