是否可以在不提供整个发布快照的情况下更改SQL Server复制过滤器?

NTD*_*DLS 3 sql-server database-replication transactional-replication

我经常被要求更改我的公司SQL Server Transactional Publications上的过滤器,其中包含数百个表和大约400GB的行数据.

每当我需要更改过滤器时,我必须完全重新整理整个出版物并将其发送给订阅者,这个过程需要将近一整天才能完成.

我的问题:可以在不提供整个发布快照的情况下更改SQL Server复制过滤器吗?

kin*_*zor 10

您必须从发布中删除表(文章)并使用新过滤器重新添加它.诀窍在于,如果在从发布中删除文章之前删除对文章的订阅,则不需要为所有文章提供整个快照 - 但仅针对单个表(以及它的新过滤器).

--Drop existing subscription:
EXEC sp_dropsubscription
                @publication='<pub_name',
                @article='<article_name',
                @subscriber='<sub_name',
                @destination_db='<db_name>',
                @ignore_distributor=0

--Drop the article from the publication:
EXEC sp_droparticle
                @publication='<pub_name',
                @article='<article_name',
                @ignore_distributor=0,
                @force_invalidate_snapshot=1
Run Code Online (Sandbox Code Playgroud)

现在,将文章添加回订阅的最简单方法是通过复制发布GUI,您可以添加文章,添加过滤器然后单击确定.运行快照作业时,它只会为单个表生成快照.这被称为迷你快照.

如果要手动将文章及其过滤器重新添加到发布中,则需要执行以下操作以将其重新添加到订阅中.

--Re-add the subscription to the article.
EXEC sp_addsubscription
                @publication = @publication='<pub_name',
                @article = @article='<article_name',
                @subscriber =  @subscriber='<sub_name',
                @destination_db='<db_name>',
                @sync_type =  'automatic ',
                @subscription_type = 'push',
                @update_mode =  'read only'
Run Code Online (Sandbox Code Playgroud)

- 您现在需要手动将任何新列添加到订阅者的目标表中,重新运行将运行迷你快照的快照代理...然后启动分发服务器.