Reputation: 1628
I have two databases, A, and B. On database A, I have a table X, with 10 columns in it. On database B, I have a table Y, with 7 columns in it. 4 of the columns from these tables match, and whenever one table updates one or more of these columns, I need the other table to update these columns. How can I do this? Replication wouldn't seem to work because the table structures are different, and insert/update triggers would seem to create infinite loops.
Upvotes: 0
Views: 365
Reputation: 294407
Replication works fine on tables with different structures, see Filtering Published Data.
As for triggers to avoid infinite loop, you would use context information to set up that you're currently in a 'replication' trigger so that you'd avoid looping, see Using Session Context Information:
CONTEXT_INFO()
says you're already in a trigger.
SET CONTEXT INFO
to reflect your operationUpvotes: 2
Reputation: 52675
To avoid the loops you could have your triggers not do an update if the values are equal?
Upvotes: 1