Delen via


Creating and Applying the Snapshot

Snapshots are generated by the Snapshot Agent after a publication is created. They can be generated:

  • Immediately. By default, a snapshot for a merge publication is generated immediately after the publication is created in the New Publication Wizard.

  • At a scheduled time. Specify a schedule on the Snapshot Agent page of the New Publication Wizard or when using stored procedures or Replication Management Objects (RMO).

  • Manually. Run the Snapshot Agent from the command prompt or from SQL Server Management Studio. For more information about running agents, see Replication Agent Executables Concepts and How to: Start and Stop a Replication Agent (SQL Server Management Studio).

For merge replication, a snapshot is generated every time the Snapshot Agent runs. For transactional replication, snapshot generation depends on the setting of the publication property immediate_sync. If the property is set to TRUE (the default when using the New Publication Wizard), a snapshot is generated every time the Snapshot Agent runs, and it can be applied to a Subscriber at any time. If the property is set to FALSE (the default when using sp_addpublication), the snapshot is generated only if a new subscription has been added since the last Snapshot Agent run; Subscribers must wait for the Snapshot Agent to complete before they can synchronize.

By default, when snapshots are generated, they are saved in the default snapshot folder located on the Distributor. You can also save snapshot files on removable media such as removable disks, CD-ROMs, or in locations other than in the default snapshot folder. Additionally, you can compress the files so that they are easier to store and transfer, and execute scripts before or after the snapshot is applied at the Subscriber. For more information about these options, see Snapshot Options.

If the snapshot is for a merge publication that uses parameterized filters, the snapshot is created using a two-part process. First a schema snapshot is created that contains the replication scripts and the schema of the published objects, but not the data. Each subscription is then initialized with a snapshot that includes the scripts and schema copied from the schema snapshot and the data that belongs to the subscription's partition. For more information, see Snapshots for Merge Publications with Parameterized Filters.

After the snapshot is created at the Publisher and stored in a default or alternate snapshot location, the snapshot can be transferred to the Subscriber and applied. The Distribution Agent (for snapshot or transactional replication) or Merge Agent (for merge replication) transfers the snapshot and applies the schema and data files to the subscription database on the Subscriber during the initial synchronization. By default, the initial synchronization occurs immediately after a subscription is created if you use the New Subscription Wizard. This behavior is controlled by the Initialize When option on the Initialize Subscriptions page of the wizard. When snapshots are generated after a subscription is initialized, they are not applied to a Subscriber unless a subscription is marked for reinitialization. For more information, see Reinitializing a Subscription.

After the Distribution Agent or Merge Agent applies the initial snapshot, the agent propagates subsequent updates and other data modifications. When snapshots are distributed and applied to Subscribers, only those Subscribers waiting for initial or new snapshots are affected. Other Subscribers to that publication (those that are already receiving inserts, updates, deletes, or other modifications to the published data) are not affected.

To create and apply the initial snapshot

To view or modify the default snapshot folder location