Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how do I use sql triggers to replicate update changes across two different databases

how do I use sql triggers to replicate update changes across two different databases

Scheduled Pinned Locked Moved Database
databasehelptutorialquestionannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GDMFSOB
    wrote on last edited by
    #1

    Hi, I have the following problem, I have 2 different databases for 2 seperate systems I some of the data in db 2 is needed in db 1, I want to create an sql trigger for ms sql 2000 that will run when ever an update happens in db 2 the fields that I want in db 1 from db 2 must update with the changes made in db 2. So my problem is in the trigger how to I get the values that where updated into the update stament I want to send to the other database CREATE TRIGGER tr_table_UPDATE ON dbo.vehicle_db1.Vechicle_list FOR UPDATE AS Update dbo.vehicle_db2.Vechicles set Registration_No = 'PYS 789 GP', Model = 'Data from the original update' where ID = 'id from original update' I hope this makes sense, in a way its kinda replication. Thank in adavance.

    A 1 Reply Last reply
    0
    • G GDMFSOB

      Hi, I have the following problem, I have 2 different databases for 2 seperate systems I some of the data in db 2 is needed in db 1, I want to create an sql trigger for ms sql 2000 that will run when ever an update happens in db 2 the fields that I want in db 1 from db 2 must update with the changes made in db 2. So my problem is in the trigger how to I get the values that where updated into the update stament I want to send to the other database CREATE TRIGGER tr_table_UPDATE ON dbo.vehicle_db1.Vechicle_list FOR UPDATE AS Update dbo.vehicle_db2.Vechicles set Registration_No = 'PYS 789 GP', Model = 'Data from the original update' where ID = 'id from original update' I hope this makes sense, in a way its kinda replication. Thank in adavance.

      A Offline
      A Offline
      andyharman
      wrote on last edited by
      #2

      If the databases are on the same server then there is no need to replicate the tables because you can reference tables using:

      select * from <database>.<owner>.<table>
      

      If the databases are on separate servers, but have reliable connectivity then consider using "linked servers" (look them up in BOL). Otherwise consider using "replication" (look it up in BOL). Hope that helps. Andy

      G 1 Reply Last reply
      0
      • A andyharman

        If the databases are on the same server then there is no need to replicate the tables because you can reference tables using:

        select * from <database>.<owner>.<table>
        

        If the databases are on separate servers, but have reliable connectivity then consider using "linked servers" (look them up in BOL). Otherwise consider using "replication" (look it up in BOL). Hope that helps. Andy

        G Offline
        G Offline
        GDMFSOB
        wrote on last edited by
        #3

        thanks man, but thats not what I need, i will have redesign the entire package if I am to go that route this is supposed to be a quick fix, I know its not ideal, but I figured it out about an hour ago thanks.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups