how do I use sql triggers to replicate update changes across two different databases
-
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.
-
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.
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
-
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