Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 519
NTDLS Avatar asked Jul 06 '11 18:07

NTDLS


People also ask

How do you add articles to replication without generating a snapshot?

To avoid generating a snapshot for all articles when adding a new article, publication property immediate_sync must be set to 0 and then call sp_addarticle, followed by sp_addsubscription. If it is pull subscription, you must call sp_refreshsubscriptions.

How do I change the snapshot folder in replication?

Change Snapshot folder Path Right-click publication and Go to properties. Go to Snapshot page on the left side and check current snapshot files path. To change the path, Right-click Replication folder and click Distribution Properties.

How does snapshot replication work?

Snapshot replication distributes data exactly as it appears at a specific moment in time and does not monitor for updates to the data. When synchronization occurs, the entire snapshot is generated and sent to Subscribers.

How do I remove snapshot replication?

Select an iSCSI LUN you wish to remove the snapshots of. Click Snapshot > Snapshot List. Select one or more snapshots you wish to remove, and click Remove.

What is snapshot agent in replication?

The Replication Snapshot Agent is an executable file that prepares snapshot files containing schema and data of published tables and database objects, stores the files in the snapshot folder, and records synchronization jobs in the distribution database.

What is difference between snapshot and transactional replication?

The differences are the mechanisms on how the data replicated from the publication to the subscriptions. For a snapshot replication, it has two agents during the replication process, snapshot agent and distribution agent; while transactional replication has an additional agent, Log Reader agent.


1 Answers

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.

like image 54
kingrazor Avatar answered Sep 29 '22 19:09

kingrazor