?
Solved

Writing trigger to transfer data between two databases

Posted on 2001-08-22
5
Medium Priority
?
271 Views
Last Modified: 2008-02-01
I have similar databases(same tables, table structure) on two diferent servers. When the data is loaded onto server1, it has to be validated and if it meets a specific condition then data need to be transfered on to the server2. I can write a trigger to do the validation and condition checking. I need help in the second part. the databases are on separate machines.
0
Comment
Question by:pappala
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Accepted Solution

by:
zahid_synentia earned 300 total points
ID: 6416646
Have a look at linked servers. You can link a server on a seperate machine and then refer to it in SQL by the server name.
0
 
LVL 1

Expert Comment

by:deestuar
ID: 6416739
You could use replication to transfer the data or call a stored procedure on the other server in a distributed transaction
0
 

Author Comment

by:pappala
ID: 6418530
Thank you for the comments. I would like to know how it has to be done. How to link servers or replicate in the trigger?
0
 
LVL 1

Expert Comment

by:deestuar
ID: 6421153
If you use replication you wouldn't need to use the trigger just set up articles for replication. Using distributed transactions you could call a remote Sp fro ma trigger. Ensure that the remote sp has a return @error this will help cathcing any errors that have occured
0
 
LVL 1

Expert Comment

by:george74
ID: 6444736
hi,

if you choose doing it with replication i suggest you doing the following. Let's say you have 2 servers, let's call them BO (BackOffice) and PUB (Publication). Assume feed arrives to FEEDDB on BO and it's parsed there. If it's ok, you want it to be transferred to server PUB, PUBDB (same structure as FEEDDB). The simplest in my opinion would be to create a 3rd DB on BO, cal it TRANSDB.
Establish replication of your choice (merge, transactional, snapshot) between BO.TRANSDB and PUB.PUBDB. So all data enterred in BO.TRANSDB will be sent over to PUB.PUBDB. Now all what remains, is to populate TRANSDB, but since it's on the same server (BO) than FEEDDB, you can simply manage it in your FEEDDB..PARSEFEED trigger, like this

if (....criterias...)
   insert into TRANSDB..YOURTABLE select * from inserted

This solution can be programmed/set up in no time (1-2 hours depending the amount of tables you wanna include in this process). Also this solution doesn't deal with data manipulation on PUB server.

I'd go with this if the criterias are real complicated. Otherwise you can simply establish replication between FEEDB and PUBDB if your criterias are simple and you can set them in the article filtering.

cheers!
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question