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.
| Author |
Topic |
|
emeriqus
Starting Member
2 Posts |
Posted - 2004-12-21 : 09:06:10
|
| I have two set of databases each of them contains a Publisher database and some Subscribers. The two Publishers reside on the same machine. The structure of databases are the same. Some tables (Products, Customers) should have the same data. They had a lot of initial data so the IDs are not the same. I couldn't see any replication architectura to solve this problem because of the IDs. I decided to write triggers for my tables on Publishers so if a new value inserted (by the user or by the merge replication agent) the row is inserted in the other Publisher but with an another ID coresponding the current identity range. BUT... If I insert a row in SubscriberA the value is propageted by replication to PublisherA and using the trigger a new value is inserted in PublisherB but with a strange ID (same to be a big random integer). If I try to insert a new value into SubscriberA the merge agent are trying to copy the data to PublisherA (with the same ID of course) it fires my trigger and try to insert a new row in PublisherB with the same strange ID. It returns with an error because of the primary key constraint and finaly the row is not inserted into the PublisherA and is deleted from SubscriberA. Can anyone help me?Here is my trigger:CREATE TRIGGER syncTablesON myTableAFTER INSERTAS IF (select trigger_nestlevel()) = 1BEGIN insert into Publisher2.dbo.myTable (myCol) select I.myCol from inserted IEND |
|
|
|
|
|