Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Location
    Montreal, Canada
    Posts
    151

    Exclamation 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.

  2. #2
    Join Date
    Aug 2004
    Location
    Calgary, Alberta
    Posts
    106
    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.

    Code:
    CREATE TRIGGER update_other_table
    ON	table
    AFTER	INSERT,UPDATE
    AS	
                IF(COLUMNS_UPDATED() & 3) > 0 --if the first two columns have been updated.
                UPDATE seconddb.table set test1 = test1,test2=test2
                ELSE
                INSERT INTO seconddb.table VALUES(test1,test2)

  3. #3
    Join Date
    Jan 2004
    Location
    Montreal, Canada
    Posts
    151
    i have tryed it but that does work

  4. #4
    Join Date
    Jan 2004
    Location
    Montreal, Canada
    Posts
    151
    Anyone ........

  5. #5
    Join Date
    Jan 2004
    Location
    Montreal, Canada
    Posts
    151
    Brettttttttttttttttttttttttt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •