Merge Replication initialization error

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 ?
aaomaraAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aaomaraAuthor Commented:
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
aaomaraAuthor Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.