October 22, 2009 at 1:32 pm
Hi!
i have two separated servers with sql 2005.
I want to make a trigger in server A that updates/insert/deletes on server B.
How do i do this ?
October 22, 2009 at 1:48 pm
Try to do it with linked server, simple link server B to the A and try to execute trigger referring the link server
October 22, 2009 at 3:22 pm
What are you trying to copy from server A to server B? Just a few columns of a few rows whenever table X gets updated on server A? Or entire tables/databases or their changes on a regular scheduled basis? If it is the former, Dugi's suggestion may be OK (although I hate triggers more than cursors, hehe, not applicable here), but otherwise I would be looking at some form of replication if I were you.
October 22, 2009 at 3:26 pm
I really must caution you on this method. If server b is not available, or that database on server b is not available, or there is a network problem the trigger will fail and the change will rollback.
If you need to keep server B updated choose another method like log shipping or transactional replication instead. The method you are looking at it rife with downsides and potential issues..
CEWII
October 22, 2009 at 3:49 pm
I have to jump on the bandwagon for this one as well. In the past, I've seen situations where triggers writing to linked servers caused severe production problems to the point that the application eventually became unusable. We re-architected the solution to do more of a dump and sweep mechanism where the trigger wrote the data locally, and some other process (a scheduled job in our situation) then picked it up and processed it downstream.
October 22, 2009 at 3:56 pm
Agreed,
Triggers updating data on linked servers promote transactions to distributed and this opens a whole lotta new possibilities of failure, mainly related to availability of the servers, network stability, firewals, and MSDTC. An asynchronous process is a much safer option. Not sure, but perhaps you could also set up replication on this table.
Regards
Piotr
...and your only reply is slàinte mhath
October 23, 2009 at 8:29 am
Thanks a lot. So i guess i have to consider a lot of facts first.
October 23, 2009 at 8:30 am
I'm going to pile on here as well. A trigger should NOT be used to update data on another server or really do any action outside the database (cross database on the same server is probably okay). In your case you want to look into Service Broker or roll your own queuing process.
I wrote an introduction to triggers article[/url] that I would recommend you read as it discusses this type of issue.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 23, 2009 at 8:53 am
transactional replication it for large amount of data???
I need to move a really small amount of data from server A to B. that´s what i thought in a trigger.
October 23, 2009 at 8:55 am
Then service broker sounds pretty good..
CEWII
October 23, 2009 at 9:55 am
i will stay with the trigger idea and see how it works.
My question now is how should the transact look to insert in one db from another.
insert into databaseengine.db.schema.table.??
October 23, 2009 at 10:02 am
I really highly recommend AGAINST doing this in a trigger. It will not scale and it is rife with problems. Use Service Broker or use a trigger to insert the data into a local table, then have a job or a windows service to process that data and insert it into the linked server.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 23, 2009 at 10:28 am
Ok. i´ll evuate the idea of using a aditional local table and a job.
thanks for the advice.
October 23, 2009 at 12:36 pm
so i know how to do what i´ve to do.
But i really want to know how do i connect to diferent DB engines from diferent servers.
thanks.
October 28, 2009 at 8:54 am
igngua (10/23/2009)
so i know how to do what i´ve to do.But i really want to know how do i connect to diferent DB engines from diferent servers.
thanks.
so...how can i do it ??
¿ just registering the engine in both servers ?
Viewing 15 posts - 1 through 15 (of 40 total)
You must be logged in to reply to this topic. Login to reply