Solved

Writing trigger to transfer data between two databases

Posted on 2001-08-22
5
249 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET 5 Templates 2 66
SQL Server - SQL field is defined as text 3 28
Help Extract Specific in SQL 8 24
SSRS troubles 4 20
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

920 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

16 Experts available now in Live!

Get 1:1 Help Now