I'm currently working on a project for a company, the company has 8 branches, each with their own server. They task me to combine the db into one to be used at the headquarter. Maybe I'm stupid but the only way that I can come up with is to replicate each database to HQ. So then HQ will have 8 database of each branches. Problem is they want data changes to be real time, so I figured snapshot isn't going to work.
So I opted to transaction, which works but from my testing, I tried deleting some record at HQ database first, then I deleted the same record from the publisher/branches. And I got this error when it tries to replicate the database,
"The row was not found at the Subscriber when applying the replicated DELETE command for Table '[dbo].[repl_tbl]' with Primary Key(s): [id] = 1 (Source: MSSQLServer, Error number: 20598)"
Another problem that I found is that, If I were to add new data with let say primary key '15' to the branch database at my HQ which currently doesn't exist yet, and then I add data with primary key '15' to the branch/publisher database, now this result in error of
"Violation of PRIMARY KEY constraint 'PK_repl_tbl'. Cannot insert duplicate key in object 'dbo.repl_tbl'. The duplicate key value is (13). (Source: MSSQLServer, Error number: 2627)"
I'm expecting the data at HQ to changed according to branch.
Any suggestion is greatly appreciated. Thanks in advance.