Aracılığıyla paylaş


Synchronize Data

Synchronizing data refers to the process of data and schema changes being propagated between the Publisher and Subscribers after the initial snapshot has been applied at the Subscriber. Synchronization can occur:

  • Continuously, which is typical for transactional replication.

  • On demand, which is typical for merge replication.

  • On a schedule, which is typical for snapshot replication.

When a subscription is synchronized, different processes occur based on the type of replication you are using:

  • Snapshot replication. Synchronization means that the Distribution Agent reapplies the snapshot at the Subscriber so that schema and data at the subscription database is consistent with the publication database.

    If modifications to data or schema have been made at the Publisher, a new snapshot must be generated in order to propagate modifications to the Subscriber.

  • Transactional replication. Synchronization means that the Distribution Agent transfers updates, inserts, deletes, and any other changes from the distribution database to the Subscriber.

  • Merge replication. Synchronization means that the Merge Agent uploads changes from the Subscriber to the Publisher and then downloads changes from the Publisher to the Subscriber. Conflicts, if any, are detected and resolved. Data is converged, and the Publisher and all Subscribers eventually end up with the same data values. If conflicts were detected and resolved, work that was committed by some of the users is changed to resolve the conflict according to policies you define.

Snapshot publications completely refresh the schema at the Subscriber every time synchronization occurs, so all schema changes are applied to the Subscriber. Transactional replication and merge replication also support the most common schema changes. For more information, see Make Schema Changes on Publication Databases.

To synchronize a push subscription, see Synchronize a Push Subscription.

To synchronize a pull subscription, see Synchronize a Pull Subscription.

To set synchronization schedules, see Specify Synchronization Schedules.

To view and resolve synchronization conflicts

Executing Code During Synchronization

Replication supports two methods of executing code during synchronization

  • On demand script execution is supported for transactional replication and merge replication. Using on demand script execution you can specify a SQL script to run during synchronization. The script is copied to the Subscriber and executed using sqlcmd at the beginning of the synchronization process. The script does not have access to the replicated changes as they are applied to the Subscriber. For more information, see Execute Scripts During Synchronization (Replication Transact-SQL Programming).

  • Business logic handlers are supported for merge replication. Using the business logic handler framework you can write a managed code assembly that is called during the merge synchronization process. The assembly includes business logic that can respond to a number of conditions during synchronization: data changes, conflicts, and errors. For more information, see Execute Business Logic During Merge Synchronization.

See Also

Detect and Resolve Merge Replication Conflicts