the replication trigger looks like this if it helps.
create trigger upd_7737C91A637746318D62051D5D1B8A21 on [dbo].[tblRenewalAccounts] FOR UPDATE AS
if sessionproperty('replication_agent') = 1 and (select trigger_nestlevel()) = 1 -- and master.dbo.fn_isreplmergeagent() = 1
return
/* Declare variables */
declare @article_rows_updated int
select @article_rows_updated = count(*) from inserted
declare @contents_rows_updated int, @updateerror int
declare @bm varbinary(500), @missingbm varbinary(500), @lineage varbinary(255), @cv varbinary(2048)
declare @tablenick int, @nick int, @ccols int, @partchange int, @joinchange int, @partgen int, @joingen int, @newgen int
declare @partchangebm varbinary(500), @joinchangebm varbinary(500)
set nocount on
set @tablenick = 30049000
select @newgen = gen_cur from sysmergearticles where nickname = @tablenick
if @newgen is null
set @newgen = 0
/* Use intrinsic funtion to set bits for updated columns */
set @bm = columns_updated()
/* only do the map down when needed */
set @missingbm = 0x00
set @partchangebm = 0x00
set @joinchangebm = 0x00
if update([rowguid])
begin
if @@trancount > 0
rollback tran
RAISERROR (20062, 16, -1)
end
/* See if the partition might have changed */
if @partchangebm = 0x0
set @partchange = 0
else
set @partchange= { fn INTERSECTBITMAPS (@bm, @partchangebm) }
/* See if a column used in a join filter changed */
if @joinchangebm = 0x0
set @joinchange = 0
else
set @joinchange= { fn INTERSECTBITMAPS (@bm, @joinchangebm) }
execute master..xp_mapdown_bitmap 0x0040, @bm output
exec dbo.sp_MSgetreplnick @nickname = @nick output
select @ccols = 15
set @lineage = { fn UPDATELINEAGE(0x0, @nick) }
set @lineage = { fn UPDATELINEAGE(@lineage, @nick) }
set @cv = { fn INITCOLVS(@ccols, @nick) }
if (@@error <> 0)
begin
goto FAILURE
end
set @cv = { fn UPDATECOLVBM(@cv, @nick, @bm, @missingbm) }
if @joinchange = 1
begin
set @joingen = @newgen
set @partgen = @newgen
end
else if @partchange = 1
begin
set @partgen = @newgen
set @joingen = NULL
end
else
begin
set @partgen = NULL
set @joingen = NULL
end
update ctsv_7737C91A637746318D62051D5D1B8A21
set lineage = { fn UPDATELINEAGE(lineage, @nick) },
generation = @newgen,
joinchangegen = case when (@joinchange = 1) then @newgen else joinchangegen end,
partchangegen = case when (@partchange = 1) then @newgen else partchangegen end,
colv1 = { fn UPDATECOLVBM(colv1, @nick, @bm, @missingbm) }
FROM inserted as I JOIN ctsv_7737C91A637746318D62051D5D1B8A21 as V
ON (I.rowguidcol=V.rowguid)
and tablenick = @tablenick
select @updateerror = @@error, @contents_rows_updated = @@rowcount
if @article_rows_updated <> @contents_rows_updated
begin
insert into ctsv_7737C91A637746318D62051D5D1B8A21 (tablenick, rowguid, lineage, colv1, generation, partchangegen, joinchangegen)
select @tablenick, rowguidcol, @lineage, @cv, @newgen, @partgen, @joingen from inserted where
rowguidcol not in (select rowguid from ctsv_7737C91A637746318D62051D5D1B8A21 where tablenick = @tablenick)
if @@error <> 0
GOTO FAILURE
end
return
FAILURE:
if @@trancount > 0
rollback tran
raiserror (20041, 16, -1)
return
|