Follow this steps.
1) Make merge replication with push subscription
2) Make a snapshot
3) Create subscriber database
4) Start synchronization
5) Create table "A" in a publisher. (scripts)
a) "CREATE TABLE [A] ( [AID] int NOT NULL IDENTITY (1, 1))"
b) "ALTER TABLE [A] ADD CONSTRAINT [Pk_AID] PRIMARY KEY ([AID])"
6) Run sp_addmergearticle (scripts)
EXEC sp_addmergearticle
@publication = 'Publ2008',
@article = 'A',
@source_object = 'A',
@identityrangemanagementoption = N'auto',
@pub_identity_range = 100000,
@identity_range = 100000,
@threshold = 80,
@schema_option = 0x0004FF1,
@force_invalidate_snapshot = 1,
@verify_resolver_signature = 0
7) Generate snapshot again

Start synchronization
9) Check if "A" table uploaded to subscriber. if succeed
10) Create table "B" in a publisher. (scripts)
a) "CREATE TABLE [B] ( [BID] int NOT NULL IDENTITY (1, 1))"
b) "ALTER TABLE [B] ADD CONSTRAINT [Pk_BID] PRIMARY KEY ([BID])"
11) Run sp_addmergearticle (scripts)
EXEC sp_addmergearticle
@publication = 'Publ2008',
@article = 'B',
@source_object = 'B',
@identityrangemanagementoption = N'auto',
@pub_identity_range = 100000,
@identity_range = 100000,
@threshold = 80,
@schema_option = 0x0004FF1,
@force_invalidate_snapshot = 1,
@verify_resolver_signature = 0
12) Add column to "A" (scripts)
"sp_repladdcolumn @source_object = '[A]', @column = 'BID' , @typetext =
'INT NULL'"
13) Add FK to "A" table (scripts)
"ALTER TABLE [A] ADD CONSTRAINT [FK_A_B_BID] FOREIGN KEY ([BID]) REFERENCES
[B] ([BID])"
14) Generate snapshot again
15) Start synchronization
Hopefully You must get errors.
"Paul Ibison" wrote:
> There's something very wrong here because the DRI scripts are applied after
> the schema scripts when initializing. Perhaps it is something to do with the
> schema of the table? Is the table created, but under a different schema to
> the one used in the FK script. Please can you post up scripts for the 2
> tables so I can reproduce. Also I didn't verify - are you adding this article
> separately and initializing it on its own, or is this part of a
> reinitialization?
> HTH,
> Paul Ibison >> Stay informed about: FOREIGN KEY problem in merge replication