后续版本的 Microsoft SQL Server 将删除该功能。请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。
The EnableMergeSubscription method enables a Subscriber-originated (pull) subscription at the Publisher and Distributor.
语法
object
.EnableMergeSubscription(
Subscriber
,
SubscriptionDatabase
,
Publication 
, [ SubscriptionType ] , [ SyncType ] , [ SubscriberType ] ,
[ SubscriptionPriority ] )
Parts
- object
 Expression that evaluates to an object in the Applies To list.
- Subscriber
 String that identifies the Subscriber by name. This is the SQL Server instance name.
- SubscriptionDatabase
 String that identifies a Microsoft SQL Server 2000 database that exists on the Subscriber and is used for replicated article storage.
- Publication
 String that identifies an existing merge replication publication maintained on the referenced database.
- SubscriptionType
 Long integer that specifies a subscription direction. Must evaluate to SQLDMOSubscription_Pull.
- SyncType
 Long integer that specifies a method for synchronization as described in Settings.
- SubscriberType
 Long integer that specifies merge Subscriber visibility as described in Settings.
- SubscriptionPriority
 Float that specifies relative priority for conflict resolution as described in Settings.
Prototype (C/C++)
HRESULT EnableMergeSubscription(SQLDMO_LPCSTR Subscriber, SQLDMO_LPCSTR SubscriptionDatabase,
SQLDMO_LPCSTR Publication,
SQLDMO_SUBSCRIPTION_TYPE SubscriptionType = SQLDMOSubscription_Pull
SQLDMO_SUBSYNC_TYPE SyncType = SQLDMOSubSync_Auto,
SQLDMO_MERGESUBSCRIBER_TYPE SubscriberType = 
SQLDMOMergeSubscriber_Local,
float SubscriptionPriority = 0.0));
Settings
Set the SyncType argument using these values.
| Constant | Value | Description | 
|---|---|---|
| SQLDMOSubSync_Auto | 1 | Subscription agent will automatically synchronize the subscription. | 
| SQLDMOSubSync_Default | 1 | SQLDMOSubSync_Auto. | 
| SQLDMOSubSync_Max | 2 | SQLDMOSubSync_None. | 
| SQLDMOSubSync_Min | 1 | SQLDMOSubSync_Auto. | 
| SQLDMOSubSync_None | 2 | Subscription agent will not attempt publication synchronization. User interaction necessary to ensure synchronization. | 
Set the SubscriberType argument using these values.
| Constant | Value | Description | 
|---|---|---|
| SQLDMOMergeSubscriber_Anonymous | 3 | Anonymous subscription. | 
| SQLDMOMergeSubscriber_Default | 2 | SQLDMOMergeSubscriber_Local. | 
| SQLDMOMergeSubscriber_Global | 1 | Global subscription. | 
| SQLDMOMergeSubscriber_Local | 2 | Local subscription. | 
When setting the SubscriptionPriority argument, use the value specified in SubscriberType to determine applicable priorities.
| SubscriberType | SubscriptionPriority | 
|---|---|
| SQLDMOMergeSubscriber_Anonymous or SQLDMOMergeSubscriber_Local | Must be 0.0. | 
| SQLDMOMergeSubscriber_Global | Value from 0.0 through 100.0. | 
备注
Creating a pull subscription using SQL Distributed Management Objects (SQL-DMO) is a two-step process. The application must define the subscription at the Subscriber, and then separately enable the subscription at the Publisher and Distributor.
To create a pull subscription to a merge replication publication
- Establish a SQLServer object connection to the Subscriber. 
- Create and populate a MergePullSubscription object. 
- Add the MergePullSubscription object to the MergePullSubscriptions collection of the appropriate ReplicationDatabase object. 
- Establish a SQLServer object connection to the Publisher. 
- Use the EnableMergeSubscription method of the appropriate ReplicationDatabase object indicating the subscription created in Step 3. 
For more information about creating pull subscriptions to merge replication publications using SQL-DMO, see MergePullSubscription Object.