Problem:
When I add a new table to the existing publication, I had to reinitialize the subscription. This creates a snapshot for all the articles present in the subscription instead of only the newly added tables. This is a problem if the size of the existing tables is huge. I want to create a snapshot only for the new tables and not all the existing tables present in the subscription.Solution:
-
The below publication property must be false to be able to achieve our requirement.
a.immediate_sync
= false
b.allow_anonymous
= false You can check these properties either in the publisher database or in the distribution database. Execute the below query to check the same.
- You need to add the tables to the publication. You can do it either through the UI or by executing the below script in the publisher database.
- After adding a new table to the publication, add a Subscription by executing the below script.
subscription_status
property will be there as 1 as we just added the subscription but it is not yet actively synchronizing.
- Start the snapshot agent to generate the snapshot of the newly added table.
- If the distribution agent job is not running, start the job. If it is already running, you can check the distribution agent’s job history. If the snapshot agent is completed, the distribution agent will automatically synchronize the new table.
- You can verify the newly added table and data are present in the subscriber server. Compare the row counts of the newly added table between the publisher and subscriber server to confirm.