Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Merge Replication initialization error

Posted on 2008-10-29
3
Medium Priority
?
2,299 Views
Last Modified: 2008-12-01
I have 2 Different server using SQL Server 2005 with SP2 in the same domain using LAN.

I establish Merge Replication between the 2 servers on one table "MMS_PO".

Note: MMS_PO table have many child tables with a foreign Keys.

At point of initialization, I got the following Error Message:
"
Error messages:
The schema script 'MMS_PO_2.sch' could not be propagated to the subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001)
Get help: http://help/MSSQL_REPL-2147201001
Could not drop object 'dbo.MMS_PO' because it is referenced by a FOREIGN KEY constraint. (Source: MSSQLServer, Error number: 3726)
Get help: http://help/3726
"

So I went to Publication properties, and I changed the Article properties in the Publication to be "Keep existing object unchanged"
Then I run the snapshot agent and mark the sunscriber for reinitialize.

I got another error :

"
Command attempted:
{call sp_MSsetconflicttable (N'EMP', N'MSmerge_conflict_REP_ABC_TEST_EMP', N'W-TIP-0302', N'ABC', N'REP_ABC_TEST')}

Error messages:
Incorrect syntax near 'EMP_NO'. (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
"

MMS_PO Table schema is as follows:

"
USE [WMMSDATA]
GO
/****** Object:  Table [dbo].[MMS_PO]    Script Date: 11/02/2008 14:44:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MMS_PO](
      [REFERENCE_ID] [varchar](20) NULL DEFAULT ('MMS'),
      [FINISH_PUB] [varchar](1) NULL DEFAULT ('N'),
      [PO_CODE] [varchar](50) NOT NULL,
      [PO_IND] [varchar](50) NULL,
      [PO_SUPPLIER] [varchar](50) NULL,
      [PO_FRDAGENT] [varchar](50) NULL,
      [PO_VENDOR] [varchar](50) NULL,
      [PO_EXPDELVDAT] [datetime] NULL,
      [PO_ORIGINOFSU] [varchar](50) NULL,
      [PO_CURRENCYS] [varchar](20) NULL,
      [PO_DESCRIPTIO] [varchar](50) NULL,
      [PO_EXPSTATUS] [varchar](1) NULL,
      [PO_POSTATUS] [varchar](1) NULL,
      [PO_POPREP] [varchar](1) NULL,
      [PO_POSTOREDEP] [varchar](50) NULL,
      [PO_CLSDATE] [datetime] NULL,
      [PO_CONFRMDATE] [datetime] NULL,
      [PO_APPROVEDCO] [varchar](50) NULL,
      [PO_FLAG] [varchar](1) NULL,
      [PO_POCLOSINGR] [varchar](50) NULL,
      [PO_PODATE] [datetime] NULL,
      [PO_CONFRMEDBY] [varchar](50) NULL,
      [PO_PEND] [varchar](50) NULL,
      [PO_LIQDAMDAYS] [int] NULL DEFAULT ((0)),
      [PO_LIQDAMDATE] [datetime] NULL,
      [PO_ACKNOLEGMENT] [varchar](100) NULL,
      [PO_ACKDATE] [datetime] NULL,
      [PO_COMMENT] [varchar](4000) NULL,
      [PO_QUOTE] [varchar](50) NULL,
      [PO_QUEDATE] [datetime] NULL,
      [PO_QUEENQUIRY] [varchar](50) NULL,
      [PO_CURRRATE] [float] NULL DEFAULT ((0)),
      [PO_ADVISEDBY] [varchar](50) NULL,
      [PO_ADVICEDATE] [datetime] NULL,
      [PO_LG] [varchar](50) NULL,
      [PO_LC] [varchar](50) NULL,
      [PO_LCREQDATE] [datetime] NULL,
      [PO_LGREQDATE] [datetime] NULL,
      [PO_REVISEDQUOTE] [varchar](1) NULL,
      [PO_LASTQUOTE] [varchar](1) NULL,
      [PO_BUYER] [varchar](50) NULL,
      [PO_INVOICED] [varchar](1) NULL,
      [PO_INVOICEDVAL] [float] NULL DEFAULT ((0)),
      [CLSDATE] [datetime] NULL,
      [PO_CLASS] [varchar](50) NULL,
      [PO_CLOSEREF] [varchar](50) NULL,
      [PO_CLOSETYPE] [varchar](50) NULL,
      [PO_REQINV] [varchar](1) NULL,
      [DELDATE] [datetime] NULL,
      [PO_AMDREF] [varchar](50) NULL,
      [PO_AMTTXT] [varchar](100) NULL,
      [PO_AMDCOUNT] [int] NULL DEFAULT ((0)),
      [ENTRYDATE] [datetime] NULL DEFAULT (getdate()),
      [PO_NEEDMRR] [varchar](1) NULL,
      [ENTRYBY] [varchar](50) NULL,
      [PO_COMPDATE] [datetime] NULL,
      [PO_LUMPSUM] [float] NULL DEFAULT ((0)),
      [PO_TYPE] [varchar](50) NULL,
      [PO_VNDACCOUNT] [varchar](50) NULL,
      [PO_NOOFITEMS] [int] NULL DEFAULT ((0)),
      [msrepl_tran_version] [uniqueidentifier] NOT NULL CONSTRAINT [MSrepl_tran_version_default_FC902993_ED1B_44A4_A0F1_5A092FC31448_725577623]  DEFAULT (newid()),
      [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [MSmerge_df_rowguid_810C9FEB043140098DADC4624A31860A]  DEFAULT (newsequentialid()),
PRIMARY KEY CLUSTERED
(
      [PO_CODE] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[MMS_PO]  WITH NOCHECK ADD  CONSTRAINT [FK_MMS_PO_PO_FRDAGENT] FOREIGN KEY([PO_FRDAGENT])
REFERENCES [dbo].[CMN_VENDOR] ([VENDOR_CODE])
ON UPDATE CASCADE
NOT FOR REPLICATION
GO
ALTER TABLE [dbo].[MMS_PO] CHECK CONSTRAINT [FK_MMS_PO_PO_FRDAGENT]
GO
ALTER TABLE [dbo].[MMS_PO]  WITH NOCHECK ADD  CONSTRAINT [FK_MMS_PO_PO_QUOTE] FOREIGN KEY([PO_QUOTE])
REFERENCES [dbo].[MMS_QUOTE] ([QUOTE_CODE])
ON UPDATE CASCADE
NOT FOR REPLICATION
GO
ALTER TABLE [dbo].[MMS_PO] CHECK CONSTRAINT [FK_MMS_PO_PO_QUOTE]
"
I don't know what to do, any one can help ?
0
Comment
Question by:aaomara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:aaomara
ID: 22865871
I succeeded to initialize to a new database, and every thing is OK.
Also I reinitialize many times after adding some data and every thing is OK.

So I thing the problem in dropping and creation of the database structure (actually in the Drop process).

I try to add Pre-Snapshot script to drop ALL Foreign Keys, but I got another error:
"
Error messages:
The schema script 'drop_FK_0.sql' could not be propagated to the subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001)
Get help: http://help/MSSQL_REPL-2147201001
"
0
 

Accepted Solution

by:
aaomara earned 0 total points
ID: 23073448
I concentrate on the First error I face :
"
Error messages:
The schema script 'MMS_PO_2.sch' could not be propagated to the subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001)
Get help: http://help/MSSQL_REPL-2147201001
Could not drop object 'dbo.MMS_PO' because it is referenced by a FOREIGN KEY constraint. (Source: MSSQLServer, Error number: 3726)
Get help: http://help/3726
"

So I generate a script to drop all foreign keys using "sp_fkys" then I generate another script to create it again.

So after I drop all the FK in the subscriber database, I succeeded to Initialize the subscriber and deliver the snapshot.

Finally I create all the FK's again and every thing is fine. :))
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question