How to dynamically add tables to replication? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to dynamically add tables to replication?

I needed to replicate a server using transactional. Problem was that every day, new tables would be added to the publisher. As far as I can tell, the only way to add new tables is to halt the publication, remove the subscriber, add the tables, start the publication snapshot again as you add the subscriber. My solution was to set up automated replication when new tables come in. They are always the same 20 tables, just different names, so a user simply needs to submit a form, and I would execute SQL code to create a new publisher, add the subscriber, and schedule the initial snapshot. I did this by spying on the replication wizard using profiler, and figuring out which stored procs where executed in the process. Though it works, I am not sure if I did everything correctly, and how stable it is. Is there a better, easier way to ensure ALL data, including new tables, can be ‘replicated’ or ‘mirrored’ on another server?
check out sp_addarticle and sp_addsubscription ***********************
Dinakar Nethi
SQL Server MVP
***********************
]]>