Solved

Writing trigger to transfer data between two databases

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

733 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