Share via


How to: Manage Partitions for a Merge Publication with Parameterized Filters (RMO Programming)

To better manage a publication with parameterized filters, you can programmatically create new Subscriber partitions, enumerate the existing Subscriber partitions, and delete Subscriber partitions by using Replication Management Objects (RMO). For information about how to create Subscriber partitions, see How to: Create a Snapshot for a Merge Publication with Parameterized Filters (RMO Programming). The following information about existing partitions can be obtained:

  • The value and filtering function upon which the partition is based.
  • The name of the job that generates a parameterized snapshot for the Subscriber.
  • The last time that a parameterized snapshot job ran.

Note

When a publication has parameterized filters that yield subscriptions with nonoverlapping partitions, and if a particular subscription is lost and needs to be re-created, you must do the following: remove the partition that was subscribed to, re-create the subscription, and then re-create the partition. For more information, see Parameterized Row Filters. Replication generates creation scripts for existing Subscriber partitions when a publication creation script is generated. For more information, see Scripting Replication.

To view information on existing partitions

  1. Create a connection to the Publisher by using the ServerConnection class.

  2. Create an instance of the MergePublication class. Set the Name and DatabaseName properties for the publication, and set the ConnectionContext property to the ServerConnection created in step 1.

  3. Call the LoadProperties method to get the properties of the object. If this method returns false, either the publication properties in step 2 were defined incorrectly or the publication does not exist.

  4. Call the EnumMergePartitions method, and pass the result to an array of MergePartition objects.

  5. For each MergePartition object in the array, get any properties of interest.

To delete existing partitions

  1. Create a connection to the Publisher by using the ServerConnection class.

  2. Create an instance of the MergePublication class. Set the Name and DatabaseName properties for the publication, and set the ConnectionContext property to the ServerConnection created in step 1.

  3. Call the LoadProperties method to get the properties of the object. If this method returns false, either the publication properties in step 2 were defined incorrectly or the publication does not exist.

  4. Call the EnumMergePartitions method, and pass the result to an array of MergePartition objects.

  5. For each MergePartition object in the array, determine whether the partition should be deleted. This decision is usually based on the value of the DynamicFilterLogin property or the DynamicFilterHostName property.

  6. Call the RemoveMergePartition method on the MergePublication object from step 2. Pass the MergePartition object from step 5.

  7. Repeat step 6 for each partition that is deleted.

See Also

Other Resources

Parameterized Row Filters
Snapshots for Merge Publications with Parameterized Filters

Help and Information

Getting SQL Server 2005 Assistance