Hi William,
We did write some sql to manually move the stuff over from
the conflict table to the article after disabling the
constraint for id ranges on that article.
We had this on quite a few tables - here is the table
schema, conflict table schema and audit trigger from one
of the simpler ones.
The failure occured because the replication user didn't
have sufficient rights to insert rows into Audit_Action
table. All of this I understand after some investigation
into the MS_merge_XXXXX role etc. I just would have
thought that the conflict resolution could have bypassed
the publisher id constraint when resolving conflicts.
thanks.
CREATE TABLE [Action] (
[iID] [int] IDENTITY (1, 1) NOT FOR REPLICATION
NOT NULL ,
[cTitle] [nvarchar] (50) COLLATE
Latin1_General_CI_AI NOT NULL ,
[cDetail] [nvarchar] (200) COLLATE
Latin1_General_CI_AI NULL ,
[iCreator] [int] NOT NULL ,
[dCreateDate] [datetime] NOT NULL ,
[dRemindDate] [datetime] NULL ,
[dActionDate] [datetime] NULL ,
[iPriority] [int] NULL ,
[iAssignee] [int] NOT NULL ,
[iActionObjectID] [int] NOT NULL ,
[iActionObjectType] [int] NOT NULL ,
[iState] [int] NOT NULL ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL
CONSTRAINT [DF__Action__rowguid__0C4DD891] DEFAULT (newid
()),
CONSTRAINT [PK_Action] PRIMARY KEY CLUSTERED
(
[iID]
) WITH FILLFACTOR = 90 ON [PRIMARY] ,
CONSTRAINT [FK_Action_Action_Priority] FOREIGN KEY
(
[iPriority]
) REFERENCES [ActionPriority] (
[iID]
),
CONSTRAINT [FK_Action_Assignee_Employee] FOREIGN
KEY
(
[iAssignee]
) REFERENCES [Employee] (
[iID]
),
CONSTRAINT [FK_Action_BusinessObject] FOREIGN KEY
(
[iActionObjectType]
) REFERENCES [BusinessObject] (
[iID]
),
CONSTRAINT [FK_Action_Creator_Employee] FOREIGN
KEY
(
[iCreator]
) REFERENCES [Employee] (
[iID]
),
CONSTRAINT
[repl_identity_range_pub_D6537857_4A0F_4435_A6D8_C10DFA6DA1
2D] CHECK NOT FOR REPLICATION ([iID] > 4500 and [iID] <
5500)
) ON [PRIMARY]
GO
CREATE TABLE [conflict_KMDSHeinekenTMDSP6_Action] (
[iID] [int] NOT NULL ,
[cTitle] [nvarchar] (50) COLLATE
Latin1_General_CI_AI NOT NULL ,
[cDetail] [nvarchar] (200) COLLATE
Latin1_General_CI_AI NULL ,
[iCreator] [int] NOT NULL ,
[dCreateDate] [datetime] NOT NULL ,
[dRemindDate] [datetime] NULL ,
[dActionDate] [datetime] NULL ,
[iPriority] [int] NULL ,
[iAssignee] [int] NOT NULL ,
[iActionObjectID] [int] NOT NULL ,
[iActionObjectType] [int] NOT NULL ,
[iState] [int] NOT NULL ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL ,
[origin_datasource] [nvarchar] (255) COLLATE
Latin1_General_CI_AI NULL ,
[conflict_type] [int] NULL ,
[reason_code] [int] NULL ,
[reason_text] [nvarchar] (720) COLLATE
Latin1_General_CI_AI NULL ,
[pubid] [uniqueidentifier] NULL ,
[MSrepl_create_time] [datetime] NULL CONSTRAINT
[DF__conflict___MSrep__740D0603] DEFAULT (getdate())
) ON [PRIMARY]
GO
CREATE TRIGGER TR_Audit_Action
ON Action
AFTER INSERT, UPDATE, DELETE
AS
BEGIN
DECLARE @columnchanges varbinary(100)
DECLARE @columnlist nvarchar(1000)
DECLARE @columninsertedlist nvarchar(1000)
DECLARE @audittype int
DECLARE @deletecount int
DECLARE @insertcount int
DECLARE @personid int
IF (ISNUMERIC(HOST_NAME()) = 1)
BEGIN
SET @personid = CONVERT(int,HOST_NAME())
END
ELSE
BEGIN
SET @personid = null
END
SELECT @insertcount = COUNT(1) FROM inserted
SELECT @deletecount = COUNT(1) FROM deleted
IF @insertcount = 0 SET @audittype = 2 /* delete */
ELSE
BEGIN
IF @deletecount = 0 SET @audittype = 0 /* insert */
ELSE SET @audittype = 1 /* update */
END
SET @columnchanges = COLUMNS_UPDATED()
EXEC sp_ColumnlistFromVarbinary @tablename = 'Action',
@columnbits = @columnchanges,
@alwaysreturnidandrowguidcolumns = 1, @pretext = '',
@imagepretext = '', @@columnlist = @columnlist OUTPUT
DECLARE @sqlstring nvarchar(2000)
SELECT
inserted.iID,inserted.cTitle,inserted.cDetail,inserted.iCre
ator,inserted.dCreateDate,inserted.dRemindDate,inserted.dAc
tionDate,inserted.iPriority,inserted.iAssignee,inserted.iAc
tionObjectID,inserted.iActionObjectType,inserted.iState,ins
erted.rowguid, GETUTCDATE() AS auditcolumn_audittime,
@personid AS auditcolumn_auditperson, @columnchanges AS
auditcolumn_auditcolumnschanged, @audittype AS
auditcolumn_auditaction, CURRENT_USER AS
auditcolumn_currentuser INTO #TR_Audit_ActionTempTable
FROM inserted INNER JOIN Action ON inserted.iID =
Action.iID
IF @insertcount > 0
BEGIN
SET @sqlstring = 'INSERT INTO Audit_Action(' +
@columnlist + ' , auditcolumn_audittime,
auditcolumn_auditperson, auditcolumn_auditcolumnschanged,
auditcolumn_auditaction, auditcolumn_currentuser) SELECT '
+ @columnlist + ', auditcolumn_audittime,
auditcolumn_auditperson, auditcolumn_auditcolumnschanged,
auditcolumn_auditaction, auditcolumn_currentuser FROM
#TR_Audit_ActionTempTable'
END
ELSE
BEGIN
IF @deletecount > 0
BEGIN
SELECT iID, GETUTCDATE() AS
auditcolumn_audittime, @personid AS
auditcolumn_auditperson, @columnchanges AS
auditcolumn_auditcolumnschanged, @audittype AS
auditcolumn_auditaction, CURRENT_USER AS
auditcolumn_currentuser INTO #TR_Audit_ActionTempTable2
FROM deleted
SET @sqlstring = 'INSERT INTO Audit_Action
(iID , auditcolumn_audittime, auditcolumn_auditperson,
auditcolumn_auditcolumnschanged, auditcolumn_auditaction,
auditcolumn_currentuser) SELECT iID,
auditcolumn_audittime, auditcolumn_auditperson,
auditcolumn_auditcolumnschanged, auditcolumn_auditaction,
auditcolumn_currentuser FROM #TR_Audit_ActionTempTable2'
END
ELSE
BEGIN
SET @sqlstring = null
END
END
EXEC(@sqlstring)
DROP TABLE #TR_Audit_ActionTempTable
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
[quoted text, click to view] >-----Original Message-----
>Hi Paul,
>
>Thank you for your update! In my opinion, as a
workaround, you may manually
>run UPDATE statement to solve the conflict instead of
using the conflict
>viewer. For information about UPDATE, please refer to SQL
Books
>Online\Transact-SQL Reference\UPDATE.
>
>However, I would like to continue researching this issue
to see if there is
>other solution, to expedite the process, coule you please
post the
>following information?
>
>- the table schema
>- the trigger
>- the log table's schema
>
>Thanks,
>
>William Wang
>Microsoft Partner Online Support
>
>Get Secure! -
www.microsoft.com/security >=====================================================
>When responding to posts, please "Reply to Group" via
>your newsreader so that others may learn and benefit
>from your issue.
>=====================================================
>
>This posting is provided "AS IS" with no warranties, and
confers no rights.
>--------------------
>| Content-Class: urn:content-classes:message
>| From: "Paul de Goede" <paul@nospam.kineticmds.com>