sp_reinitmergepullsubscription (Transact-SQL)

将合并请求订阅标记为在合并代理下一次运行时重新初始化。此存储过程在订阅服务器上针对订阅数据库执行。

主题链接图标Transact-SQL 语法约定

语法

sp_reinitmergepullsubscription [ [ @publisher = ] 'publisher' ]
    [ , [ @publisher_db = ] 'publisher_db' ]
    [ , [ @publication = ] 'publication' ]
    [ , [ @upload_first = ] 'upload_first'

参数

  • [ @publisher = ] 'publisher'
    发布服务器的名称。publisher 的数据类型为 sysname,默认值为 ALL。
  • [ @publisher_db= ] 'publisher_db'
    发布服务器数据库名。publisher_db 的数据类型为 sysname,默认值为 ALL。
  • [ @publication = ] 'publication'
    发布名。publication 的数据类型为 sysname,默认值为 ALL。
  • [ @upload_first = ] 'upload_first'
    表示在重新初始化订阅之前是否上载订阅服务器上的更改。upload_first 的数据类型为 nvarchar(5),默认值为 FALSE。如果为 True,则在重新初始化订阅之前将上载更改。如果为 False,则不上载更改。

返回代码值

0(成功)或 1(失败)

备注

sp_reinitmergepullsubscription 用于合并复制。

如果添加、删除或更改参数化筛选器,则订阅服务器上挂起的更改在重新初始化期间将无法上载到发布服务器。若要上载挂起的更改,请在更改筛选器前同步所有订阅。

权限

只有 sysadmin 固定服务器角色成员或 db_owner 固定数据库角色成员才能执行 sp_reinitmergepullsubscription

示例

-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables  
-- on the command line and in SQL Server Management Studio, see the 
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".

DECLARE @publicationDB AS sysname;
DECLARE @publication AS sysname;
SET @publicationDB = N'AdventureWorks';
SET @publication = N'AdvWorksSalesOrdersMerge';

USE [AdventureWorksReplica]

-- Execute at the Subscriber to reinitialize the pull subscription. 
-- Pending changes at the Subscrber are lost.
EXEC sp_reinitmergepullsubscription 
    @publisher = $(PubServer),
    @publisher_db = @publicationDB,
    @publication = @publication,
    @upload_first = N'false';
GO

-- Start the Merge Agent.

-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables  
-- on the command line and in SQL Server Management Studio, see the 
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".

DECLARE @publicationDB AS sysname;
DECLARE @publication AS sysname;
SET @publicationDB = N'AdventureWorks';
SET @publication = N'AdvWorksSalesOrdersMerge';

USE [AdventureWorksReplica]

-- Execute at the Subscriber to reinitialize the pull subscription, 
-- and upload pending changes at the Subscriber. 
EXEC sp_reinitmergepullsubscription 
    @publisher = $(PubServer),
    @publisher_db = @publicationDB,
    @publication = @publication,
    @upload_first = N'true';
GO

-- Start the Merge Agent.

请参阅

参考

系统存储过程 (Transact-SQL)

其他资源

How to: Reinitialize a Subscription (Replication Transact-SQL Programming)
重新初始化订阅

帮助和信息

获取 SQL Server 2005 帮助