Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Merge Replication initialization error

Posted on 2008-10-29
3
Medium Priority
?
2,345 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
  • 2
2 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

824 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