triggers operating on synchronous replicated server

Posted on 2013-01-14
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.
Question by:rdun25
LVL 28

Accepted Solution

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.

Author Comment

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.

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TSQL query to generate xml 4 35
T-SQL: New to using transactions 9 31
replace \ by - in select 4 21
average of calculation (TSQL) 4 5
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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 the fundamental information of how to create a table.

803 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