Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Replication (2005)
 Foreign Key Constraints -Error 3726

Author  Topic 

buraktuf
Starting Member

13 Posts

Posted - 2008-11-25 : 04:27:28
Hello,
i need to design a merge replication system between a publiaher and two subscribers. let the name of the db which should be replicated is "DMS". the DMS db should be in the same form as the publisher site at the subscribers. that means the DMS should appear at the subscribers with same relations such foreign keys as the publishers DMS. i've tried to attach the DMS to each subscribers before the replication.so the same relations are on the subscribers. and when i start the replication in this situation i get an error such "table X could not be dropped because it is referenced by a foreign key constraint". also the trancate option also doesnt work. then i have tried to start the replication with newly created dbs on the subscribers. but after the snapshot there is no relations and foreign keys between the tables at the subscribers naturally. however i know that i can create the relation by joining the tables at the filter section. but i have 326 tables which are related to each other in a very complex level. so it doesnt work for my situation. how can i realize this system? is there any way? please help me. thanks for all replies.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-11-25 : 09:45:20
Instead of doing manually, Can you rely on Replication wizard to handle all these things?
Go to Top of Page

buraktuf
Starting Member

13 Posts

Posted - 2008-11-25 : 13:46:11
ok, thanks for reply. but what kind of a handle should it be? i have tried almost all the options in the wizard. can you help with further more information please?
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-11-25 : 13:58:18
Did you choose all tables in publisher and Create New DB with same name(With Rep Wizard) on Subscribers and start replication?
Go to Top of Page

buraktuf
Starting Member

13 Posts

Posted - 2008-11-26 : 12:52:30
yes i try to create a new database on subscriber site during the wizard steps. but i doesnt work because for a new database, after the replication starts and the new database will be filled with the replicated tables, there will not be any relations between tables such as foreign keys.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-11-26 : 14:05:30
You have to choose all articles that are related in Publisher. Check the properties of articles in Publisher and see whether 'copy foreign keys constraints to subscribers' is 'true' or not.

Alternatively, You can do Merge Replication with Backup/Restores and choose sync_type in subscribers to 'initialize with backup'
Go to Top of Page

buraktuf
Starting Member

13 Posts

Posted - 2008-11-27 : 02:10:02
thank you again very very much for your interest. what should i select for this property "Copy foreign key" in my situation? i just want to replicate also the foreign key relations. i said that i have 360 tables. and when i set copy foreign key to true how will it work? should i add all my tables in a replication to copy all the relations between all tables? because i have several replications. i cant understand. please help me.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-11-27 : 08:24:45
First you have to find how tables are related and choose them accordingly in publishers. You need to have child table to have foreign key in effect.Are you doing for whole database or subset of database?
Go to Top of Page

buraktuf
Starting Member

13 Posts

Posted - 2008-11-27 : 17:47:28
but i should set the replication for whole databse that means 360 tables. and i cant select the tables according to their foreign key relations in replication. i've got all the relations in mind but as i said i need different types of merge replication such scheduled and run continiously.therefore i cant get all the tables in a replication.
Go to Top of Page
   

- Advertisement -