Unanswered: Syncronizing 2 indentical tables in 2 different db
What iam trying to do here is syncronize 2 indentical table in 2 different db on the same server basically i have table A and table B witch have 5 columns
test1,test2,test3,test4,test5 the key is test1 and test2 for those 2 tables.
when there is a change in table A i need to check table B to see if it exist if it does update the same record with the same values if it dosent then insert that record and when i delete a record out of table A i need to delete the same record in table B.
PLZ can anyone help me with this ..iam figuring that i could probabebly do this with a trigger but how to code it ...iam in the dark here any help would be greatly apreciated it.
I know it's bad practice, but you could use a trigger to check that other table has the record and if not update it. Look in books online to further this. You may have to further qualify your column names.
CREATE TRIGGER update_other_table
IF(COLUMNS_UPDATED() & 3) > 0 --if the first two columns have been updated.
UPDATE seconddb.table set test1 = test1,test2=test2
INSERT INTO seconddb.table VALUES(test1,test2)