Solved

Merge Replication initialization error

Posted on 2008-10-29
3
2,240 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 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