I'm trying to setup a merge replication between two SQL Servers as follows:
- The publisher is SQL Server 2014 (SP2) Developer edition
- The subscriber is SQL Server 2012 (SP3) Developer edition
Generating the snapshot completed successfully, however when applying the snapshot on the subscriber I am getting the following error:
Command attempted:
{call sp_MSsetconflicttable (N'DMCOLLPKGEXCEPTION', N'MSmerge_conflict_MaxLoadBalance_Repl_DMCOLLPKGEXCEPTION', N'MAXIMO-1-RND\SQL2014', N'MaxTest', N'MaxLoadBalance_Repl')}
Error messages:
Incorrect syntax near 'exception'. (Source: MSSQLServer, Error number: 102)
Get help: http://help/102
The merge process was unable to deliver the snapshot to the Subscriber. If using Web synchronization, the merge process may have been unable to create or write to the message file. When troubleshooting, restart the synchronization with verbose history logging and specify an output file to which to write. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001)
Get help: http://help/MSSQL_REPL-2147201001
I've opened the profiler to find where this syntax error is happening, and the following is what I found:
![]()
as you can see the statement starts with the name of the column with no select nor update and ends with from and where clause! ... the following is a copy of the whole script:
Create procedure dbo.[MSmerge_cft_sp_BAAC1138E0234F895E23FB4F2043447C] ( @p1 varchar(30),
@p2 varchar(255),
@p3 smallint,
@p4 smallint,
@p5 varchar(20),
@p6 varchar(20),
@p7 text,
@p8 text,
@p9 bigint,
@p11 smallint,
@p12 varchar(4),
@p13 uniqueidentifier,
@p14 nvarchar(255) , @conflict_type int, @reason_code int, @reason_text nvarchar(720) , @pubid uniqueidentifier, @create_time datetime = NULL , @tablenick int = 0, @source_id uniqueidentifier = NULL, @check_conflicttable_existence bit = 0 ) as
declare @retcode int
-- security check
exec @retcode = sys.sp_MSrepl_PAL_rolecheck @objid = 1804646999, @pubid = '5E23FB4F-2043-447C-BDBE-E1689887F970'
if @@error <> 0 or @retcode <> 0 return 1
if 1 = @check_conflicttable_existence
begin
if 1804646999 is null return 0
end
if @source_id is NULL
select @source_id = subid from dbo.sysmergesubscriptions
where lower(@p14) = LOWER(subscriber_server) + '.' + LOWER(db_name)
if @source_id is NULL select @source_id = newid()
set @create_time=getdate()[exception] = @p1 ,
[description] = @p2 ,
[userdefined] = @p3 ,
[enabled] = @p4 ,
[exceptioncfgobject] = @p5 ,
[dependentcfgobject] = @p6 ,
[exceptioncondition] = @p7 ,
[exceptioninstr] = @p8 ,
[dmcollpkgexceptionid] = @p9 ,
[hasld] = @p11 ,
[langcode] = @p12 ,
[rowguid] = @p13 from [dbo].[MSmerge_conflict_MaxLoadBalance_Repl_DMCOLLPKGEXCEPTION] ct inner join MSmerge_conflicts_info info
on ct.rowguidcol=info.rowguid and
ct.origin_datasource_id = info.origin_datasource_id
end
else
begin
insert into [dbo].[MSmerge_conflict_MaxLoadBalance_Repl_DMCOLLPKGEXCEPTION] ( [exception] ,
[description] ,
[userdefined] ,
[enabled] ,
[exceptioncfgobject] ,
[dependentcfgobject] ,
[exceptioncondition] ,
[exceptioninstr] ,
[dmcollpkgexceptionid] ,
[hasld] ,
[langcode] ,
[rowguid] ,
[origin_datasource_id] ) values (
@p1 ,
@p2 ,
@p3 ,
@p4 ,
@p5 ,
@p6 ,
@p7 ,
@p8 ,
@p9 ,
@p11 ,
@p12 ,
@p13 ,
@source_id )
end
declare @error int
set @error= @reason_code
declare @REPOLEExtErrorDupKey int
declare @REPOLEExtErrorDupUniqueIndex int
set @REPOLEExtErrorDupKey= 2627
set @REPOLEExtErrorDupUniqueIndex= 2601
if @error in (@REPOLEExtErrorDupUniqueIndex, @REPOLEExtErrorDupKey)
begin
update mc
set mc.generation= 0
from dbo.MSmerge_contents mc join [dbo].[dmcollpkgexception] t on mc.rowguid=t.rowguidcol
where
mc.tablenick = 6399000 and
(
(t.[dmcollpkgexceptionid]=@p9) or
(t.[exception]=@p1)
)
end
I went to the publisher snapshot folder and in all the files titled with something like "DMCOLLPKGEXCEPTION" I have searched for "Create proceduredbo.[MSmerge_cft_sp_BAAC1138E0234F895E23FB4F2043447C]" (which is the first line of the script) and I found the following (the part that I think it is missing is in bold):
Create procedure dbo.[MSmerge_cft_sp_BAAC1138E0234F895E23FB4F2043447C] (
@p1 varchar(30),
@p2 varchar(255),
@p3 smallint,
@p4 smallint,
@p5 varchar(20),
@p6 varchar(20),
@p7 text,
@p8 text,
@p9 bigint,
@p11 smallint,
@p12 varchar(4),
@p13 uniqueidentifier,
@p14 nvarchar(255)
, @conflict_type int, @reason_code int, @reason_text nvarchar(720)
, @pubid uniqueidentifier, @create_time datetime = NULL
, @tablenick int = 0, @source_id uniqueidentifier = NULL, @check_conflicttable_existence bit = 0
) as
declare @retcode int
-- security check
exec @retcode = sys.sp_MSrepl_PAL_rolecheck @objid = 1096460707, @pubid = '5E23FB4F-2043-447C-BDBE-E1689887F970'
if @@error <> 0 or @retcode <> 0 return 1
if 1 = @check_conflicttable_existence
begin
if 1096460707 is null return 0
end
if @source_id is NULL
select @source_id = subid from dbo.sysmergesubscriptions
where lower(@p14) = LOWER(subscriber_server) + '.' + LOWER(db_name)
if @source_id is NULL select @source_id = newid()
set @create_time=getdate()
if exists (select * from MSmerge_conflicts_info info inner join [dbo].[MSmerge_conflict_MaxLoadBalance_Repl_DMCOLLPKGEXCEPTION] ct
on ct.rowguidcol=info.rowguid and
ct.origin_datasource_id = info.origin_datasource_id
where info.rowguid = @p13 and info.origin_datasource = @p14 and info.tablenick = @tablenick)
begin
update [dbo].[MSmerge_conflict_MaxLoadBalance_Repl_DMCOLLPKGEXCEPTION] with (rowlock) set
[exception] = @p1
,
[description] = @p2
,
[userdefined] = @p3
,
[enabled] = @p4
,
[exceptioncfgobject] = @p5
,
[dependentcfgobject] = @p6
,
[exceptioncondition] = @p7
,
[exceptioninstr] = @p8
,
[dmcollpkgexceptionid] = @p9
,
[hasld] = @p11
,
[langcode] = @p12
from [dbo].[MSmerge_conflict_MaxLoadBalance_Repl_DMCOLLPKGEXCEPTION] ct inner join MSmerge_conflicts_info info
on ct.rowguidcol=info.rowguid and
ct.origin_datasource_id = info.origin_datasource_id
where info.rowguid = @p13 and info.origin_datasource = @p14 and info.tablenick = @tablenick
end
else
begin
insert into [dbo].[MSmerge_conflict_MaxLoadBalance_Repl_DMCOLLPKGEXCEPTION] (
[exception]
,
[description]
,
[userdefined]
,
[enabled]
,
[exceptioncfgobject]
,
[dependentcfgobject]
,
[exceptioncondition]
,
[exceptioninstr]
,
[dmcollpkgexceptionid]
,
[hasld]
,
[langcode]
,
[rowguid]
,
[origin_datasource_id]
) values (
@p1
,
@p2
,
@p3
,
@p4
,
@p5
,
@p6
,
@p7
,
@p8
,
@p9
,
@p11
,
@p12
,
@p13
,
@source_id
)
end
if exists (select * from MSmerge_conflicts_info info where tablenick=@tablenick and rowguid=@p13 and info.origin_datasource= @p14 and info.conflict_type not in (4,7,8,12))
begin
update MSmerge_conflicts_info with (rowlock)
set conflict_type=@conflict_type,
reason_code=@reason_code,
reason_text=@reason_text,
pubid=@pubid,
MSrepl_create_time=@create_time
where tablenick=@tablenick and rowguid=@p13 and origin_datasource= @p14
and conflict_type not in (4,7,8,12)
end
else
begin
insert MSmerge_conflicts_info with (rowlock)
values(@tablenick, @p13, @p14, @conflict_type, @reason_code, @reason_text, @pubid, @create_time, @source_id)
end
declare @error int
set @error= @reason_code
declare @REPOLEExtErrorDupKey int
declare @REPOLEExtErrorDupUniqueIndex int
set @REPOLEExtErrorDupKey= 2627
set @REPOLEExtErrorDupUniqueIndex= 2601
if @error in (@REPOLEExtErrorDupUniqueIndex, @REPOLEExtErrorDupKey)
begin
update mc
set mc.generation= 0
from dbo.MSmerge_contents mc join [dbo].[dmcollpkgexception] t on mc.rowguid=t.rowguidcol
where
mc.tablenick = 6399000 and
(
(t.[dmcollpkgexceptionid]=@p9)
or
(t.[exception]=@p1)
)
end
I am no sure if I'm looking to the right places, but anyway, is this a bug? or it is me who did something wrong? ... how can this be fixed anyway?