Solved

Writing trigger to transfer data between two databases

Posted on 2001-08-22
5
247 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
5 Comments
 
LVL 1

Accepted Solution

by:
zahid_synentia earned 100 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now