Solved

triggers operating on synchronous replicated server

Posted on 2013-01-14
2
227 Views
Last Modified: 2013-01-21
I am (unfortunately) using SQL-Server 2005.

I am working on an application which needs to track changes to a sql-server database. I have written triggers for the sql database that record the necessary details in new tables, which the application then reads, then modifies to indicate that they have 'synced'. (i.e.: There is a synced column which defaults to 0, then when the application has read it, the application sets the column to 1)

The application will read the data from a sql-server that is replicated (synchronously) from the main database. Like this:

Office sql-server  ----->   sql-server B <-------> Application

The only information that the application commits to the sql-server B is to change the synced columns from 0 to 1 when it has read them.

Is there a way to have the triggers fire on sql-serverB only, for changes made to tables on the office server?

I have 2 reasons for wanting this:

1) server load: Some of the triggers query complex views, so i'd rather that processing was done by sql-server B.
2) safety: We want to modify the office sql-server as little as possible. The office server is mission critical, sql-server B is not.
0
Comment
Question by:rdun25
2 Comments
 
LVL 28

Accepted Solution

by:
Ryan McCauley earned 500 total points
ID: 38784429
I'm a little unclear on your configuration here - are you using native SQL Server replication (and if you are, are you using transactional replication or one of the other methods?) or have you rolled your own replication engine (using triggers)? If you're using transactional replication, it only plans changed data from the first server to the second, and you're free to issue whatever updates you want against the destination table as part of any other support process you want. In this case, you can replication your row from Server A -> B, have an application read the table on Server B, and then modify the "processed" column on Server B and set it to true. As long as nothing on Server A modifies that column on Server A afterwards, there's no issue - you can even update the table on server A and change any other values if you want, and it will replicate those changes, but it won't reset the value on the "processed" column.

If you've rolled your own replication, how is it set up? Why roll it on your own instead of using the native replication processes? You're effectively managing a queue of table changes here, and that can get more complicated if you've got anything more than very simple requirements (especially if your application that's reading the changes from Server B is multi-threaded).

If I haven't answered your question above, please provide some more detail about your configuration and I'm happy to give advice to your particular situation.
0
 

Author Comment

by:rdun25
ID: 38803557
I am very sorry about the late response.

First off, thank you, you have answered the question I needed answered. I'm sorry I wasn't clear enough about what exactly I was after.

Yes, I'm using transactional replication from server A -> B. However, the application does not have a sql database (it uses couchDB, long story). It is for the server b -> application interaction that I needed to write the triggers.

I will write a separate question to deal with the issues that come up from this.
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

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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

862 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

28 Experts available now in Live!

Get 1:1 Help Now