Article ID: 238254 - Last Review: May 12, 2008 - Revision: 6.2 UPDATE Statements May be Replicated as DELETE/INSERT PairsThis article was previously published under Q238254 SUMMARYIf any column that is part of a unique constraint
is updated, then SQL Server implements the update as a "deferred update", which
means as a pair of DELETE/INSERT operations. This "deferred update" causes replication to send a
pair of DELETE/INSERT statements to the subscribers. There are also other situations
that might cause a deferred update. Therefore, any business logic that you
implement in your UPDATE triggers or custom stored procedures at the Subscriber should
also be included in the DELETE/INSERT triggers or custom stored procedures. MORE INFORMATION The default behavior in transactional replication is to use
INSERT, UPDATE and DELETE custom stored procedures to apply changes at the
subscribers. INSERT statements made at the Publisher are applied to subscribers through an INSERT stored procedure call. Similarly, a DELETE statement is applied through a DELETE stored procedure call. However, when an UPDATE statement is executed as a "deferred update", the logreader agent places a pair of DELETE/INSERT stored procedure calls in the distribution database to be applied to the Subscribers rather than an update stored procedure call. For example, suppose you have a publishing table, named TABLE1, with these three columns:
When you execute this code: If you prefer to use single logic and you want all your UPDATE commands replicated as DELETE/INSERT pairs, you can enable a trace flag as described in this Microsoft Knowledge Base article: 160181
(http://support.microsoft.com/kb/160181/EN-US/
)
INF: Trace Flag to Replicate UPDATE as DELETE/INSERT Pair
In the preceding example, assume that you also have a horizontal filter defined on TABLE1: where col2 = 'Dallas'. If you execute this code: Now, if you execute this code: Although an UPDATE operation was performed at the Publisher, only the appropriate commands are applied at the Subscriber. REFERENCES For SQL Server 2000 Service Pack 1, or later, see the
following article in the Microsoft Knowledge Base:
302341
(http://support.microsoft.com/kb/302341/EN-US/
)
INF: New Trace Flag to Enable Singleton Update for Transactional Replication
| Article Translations
|
Back to the top
