.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Replication triggers

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :Sql Server

Hi there,

When replication created do they create triggers to replicate the data? if yes can i make my triggers run before replication triggers.


View Complete Post

More Related Resource Links

SQL Server 2008 Merge Replication article triggers not replicating


Currently running merge replication on SQL Server 2008 10.0.1600 and having issues with adding and modifying triggers on published articles.  I've searched through the MSDN site and googled it but have not found any definitive information on correct procecdures.

We have a replicated table that had 1 trigger on it when it was added to the publication.  That trigger was replicated.  We have since added a 2nd trigger to the table and it is not being replicated to our other server.  I've checked the Article Properties and Copy User Triggers is set to TRUE.  The only difference is the new trigger has NOT FOR REPLICATION in it, but I thought that would only keep it from being executed if a row is effected by the MERGE process.

We have rerun the snapshot and are syncing continuosly and the trigger does not replicate.  Do I have to drop the tablefrom the publication and then re-add it?  Am I missing something? 


Replication triggers



When replication are created do they create triggers to replicate data?if yes  how can i run my triggers before replication triggers.


Triggers and Replication


I have a few triggers created on the subscriber that fire whenever a certain table gets updated with a row. The Replication is transactional and the has a latency about 14 mins. 

1. What problems can triggers cause and what all do i need to be aware off?

I had created triggers earlier on the subscription and they failed the entire replication as it on error it tried to rollback transaction. Please help. Thanks

using triggers to keep all versions of rows after update, delete + replication

I maintain an application that uses SQL 2005 / 2008 for data persistence.
Some clients use Merge Replication (pull or push) to replicate data.

Some of the tables contain information that should never be erased.
All versions of a row from such a table should be stored, somewhere in a database.

This means all updates and deletes to those rows should result in in 2 affected rows:
• a copy of the row before the change
• a row containing the change (or the deletion of the row in question)

I plan to achieve this using AFTER UPDATE,DELETE triggers on all the tables for which "versioning" is required.
The old versions of a row may be stored in the same database, an other database (or a database on a linked server).

I was hoping to do this by creating NOT FOR REPLICATION triggers on the published database.
The theory was:
All update and delete queries performed against a subscribed database should be replicated (for concurrency) to the publisher.
When the updates and deletes are replicated, the triggers on the published database will be fired, thus also updating the table containing the version rows.

There seem to be 2 problems with this approach:
An update query against a table of the subscriber wil often result in mupltiple update queries performed ag

Changing NOT FOR REPLICATION attribute for triggers


Hi all,

Is it possible to force SQL Server to add NOR FOR REPLICATION attribute to all triggers while they are being transfered to subsriber? Or manually I should alter them one by one?

Many thanks in advance,


Data Points: Disabling Constraints and Triggers


What to do when you need to disable triggers and constraints to perform data synchronization and other tasks with an offline database.

John Papa

MSDN Magazine April 2007

Can I use TCP sockets within managed funcs, triggers and stored procedures?

I have seen nothing prohibiting this, but have not yet had time to write some test code. Does anyone know for sure if SQL Server 2008 prohibits or allows TCP sockets for communications, inside a C# SQL/CLR function or method? I guess it must because this is implict when creating data connections and so on, which are obvioulsy allowed. Thanks Cap'n  

I have 3 triggers defined on an sqlserver2008 table and I can't find them with c#

I've got the code below and when I run it, it always says there are 0 triggers in table.Triggers.  I added some debugging code checkin the table.HasDeleteTrigger, etc. and from that, I get the exception: "To accomplish this action, set property HasDeleteTrigger." when I try to set it to bool hasDeleteTrigger. I can get stored procedures find, just not triggers. Below is my problem code: foreach (Database database in databaseCollection) { if (database.Name.Equals(catalogName)) { // first we need to delete triggers associated with all tables that begin // with our prefix. we can skip our the framework tables because those // don't have triggers on them // grab all tables, filter for non prefixed ones in foreach loop so we can delete triggers from non prefixed ones results.AddRange(from Table table in database.Tables select table.Name); foreach (var tableName in results) { var table = new Table(database, tableName, CrSyncDbSchemaName); table.Refresh(); bool hasDeleteTrigger = table.HasDeleteTrigger; bool hasAfterTrigger = table.HasAfterTrigger; bool hasInsertTrigger = table.HasInsertTrigger;

merge replication system tables fragmentation issue

I have Merge replication going on in my environment. The problem is that system tables like MSmerge_content, MS merge _tombstone and MSmerge_genhistory are getting fragmented. We are rebuilding indexes time to time daily. But we want some good fix. Just send some good idea guys?

peer to peer replication, drop and add article of same name

We have peer-to-peer replication set up on our system (2005 EE). I would like to change the metadata of one of the tables (many of the tables actually, but right now I'm just trying to test out the process with just one table). As this is a high-availability system, I would like to stop the replication, make the changes on one node, verify that the changes are working, make the same changes on the other node, then re-enable replication. The ddl changes to the table are extensive enough that I have to clear them before executing. So I will handle re-populating the tables in a later step. Right now I'm just testing the process of stopping, doing ddl, then restarting. I am trying to implement this using scripts so as to minimize my clicking (and thus potential for mistakes) when doing it for real. I find that if I do the following process using the SSMS interface it goes smoothly with no errors (note that each step is conducted on both nodes unless specified): stop sync agents manually remove article: tblName1 with 'publications properties window' close 'publications properties window' make ddl changes to tblName1 (change column names, add columns etc. to a particular table) manually add article: tblName1 with 'publications properties window' re-enable agents But if I try the following, I get 'Peer-To-Peer topologies require identical articles in publications at all n

Transactional replication: Updates to one of my columns (sometimes) does not get replicated from the

hi, This is my scenario: I have a varchar(max) column on a table that is replicated to other servers. I have a stored procedure that does and update to this column and other columns on the table. This is done inside a transaction that also includes other updates. When I call the stored procedure, this one varchar(max) column's value is not replicated. When I just run the single update statement on its own, the value is replicated. Anyone know something about this? Thanks!    

Steps by Step document for configuration Merge Replication in 2005

Hi , Can anyone provide link to configure Merge Replication in 2005 with print screen.Also let me know the difference between Transcation level and Merge Replication. regards Vijay  

transactional replication and sp_MSupd tables

Hi thre, My target server keeps running sp_MSupd sp for different values in profiler and synch status shows "delivering replication commands" I keep waiting but this never ends. and ultimately we run a snapshot and it can't be applied. So recreate the whole replication again. It runs fine for a while but again, the sp_MSupd sp starts running on the target server and the replication goes down again. I don't know how to fix this. any advices?   Regards

Real-time data replication

Are there any ways to replicate sql server production database to a standby database? I notice that there is a feature called 'continuous replication', does it do in real-time? what is the time-lag? Are there any potential data loss (i.e., production transaction committed but production db corrupted before the transaction is sent to standby)? Is the standby database available for read access during the replication?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend