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

发布于 2024-11-18 22:09:03 字数 175 浏览 3 评论 0原文

我经常被要求更改我公司 SQL Server 事务发布的过滤器,其中包含数百个表和大约 400GB 的行数据。

每次需要更改过滤器时,我都必须完全重新拍摄整个出版物并将其交付给订阅者,这个过程几乎需要一整天才能完成。

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

I am constantly asked to change the filters on my companies SQL Server Transactional Publications which contain several hundred tables and roughly 400GBs of row data.

Each time I am required to alter a filter, I have to completely re-snapshot the entire publication and deliver it to the subscriber, a process which takes nearly an entire day to complete.

My question: It is possible to alter SQL Server replication filter without delivering an entire publication snapshot?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮世清欢 2024-11-25 22:09:03

您必须从出版物中删除表格(文章),然后使用新的过滤器重新添加它。诀窍是,如果您在从发布中删除文章之前删除对该文章的订阅,则不需要为所有文章提供完整快照 - 而仅针对单个表(并且它是新的过滤器)。

--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

现在,将文章添加回订阅的最简单方法是通过复制发布 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'

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

You have to drop the table (article) from the publication and re-add it with a new filter. The trick is that if you remove the subscription to the article before removing the article from the publication, you will not be required to deliver an entire snapshot for all article – but only for the single table (and it’s new filter).

--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

Now, the easiest way to add the article back to the subscription is through the replication publication GUI,
you can add the article, add the filter then click ok. When you run the snapshot job, it will only generate a snapshot for the single table. This is known as a mini-snapshot.

If you want to manually re-add the article and its filter to the publication then you'll need to do the following to get it back into the subscription.

--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'

--You will now need to manually add any new columns to the destination table at the subscriber, re-run the snapshot agent which will run a mini-snapshot... then kick off the distributor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文