How to add an article to an existing Transactional Subscription initialized through backup
Microsoft SQL Server Support
There are situations where you initialize a Transactional subscription from a backup and later you need to add an article. If the publication was created using Snapshot Replication, you can re-run the Snapshot Agent and only the newly added article is BCP’ed out then BCP’ed in at the subscriber. However when setting up the Subscriber using backup/restore there is no Snapshot agent.
There are two options when a new tables needs to be published.
1) Create a NEW publication for just that article. Use Publication Wizard or script and select default options to push a new snapshot to the subscriber. One LogReader will handle both publications, while separate Distribution Agents will move data in parallel to the subscriber.
2) Use the steps below to add the NEW article to an existing Publication and manually sync the data before restarting Replication.
Here are the steps for option 2):
1. Stop the log reader agent
2. Stop making changes to the new article in the Publisher (Note that table should be quiesced to all changes while the data is being copied out from the publisher and until the table is added to the publication with sp_addarticle)
3. Generate a script to create the table on the subscriber and copy the data out of the article from Publisher to Subscriber.
A. For new or small tables you can use INSERT INTO… SELECT * FROM
B. For tables with a lot of existing data, create a SSIS package that creates and then load the table on the remote server
4. Add the article to the publication using sp_addarticle
5. Start Log Reader Agent
6. Now you can start to make changes as the log reader will start tracking changes for the article at this point.
Please note that if the backup already had the article and if it is still present in the subscriber and provided there is no schema change is done to that table, you don’t need to create it again in the subscriber.
Also compare the row count of the table being added between publisher and subscriber before starting log reader agent to make sure that both publisher and subscriber have the same amount of data.
posted by Chris Skorlinski