Add Tables to Replication

  • Hi,

    How to had more tahn 100 tables to an existing replication?

    Now i am using sp_addarticle for each table. Is ther any other way?

    TIA

  • I think you could use the GUI and select the tables with check marks.

    Is that what you're asking ?

  • Try with

    Exec sp_MSforeachdb

    Not sure about it have a try.

    Thanks
    Parthi

  • Ratheesh.K.Nair (4/14/2011)


    Hi,

    How to had more tahn 100 tables to an existing replication?

    Now i am using sp_addarticle for each table. Is ther any other way?

    TIA

    100 more tables? If your ending up replicating most of your database you may want to look into other types of data availability like mirroring and log shipping.

    If the extra 100 tables are not your full DB then yeah, add them through the GUI it doesnt take that long.

  • Why don't you try to identify the tables from sysobjects

    and use a cursor to use sp_addarticle for each of this tables.

    The other thing that you can do is to use MS word Mail Merge

    You add one table script it out and using mailmerge it will generate the scripts for all the other tables that you need.

    Run the script on the server and you are done.

  • From experience, adding tables to a publication through the GUI is a bad idea. IT can trigger a force_reinitialisation.

    Use sp_addarticle. You will also need to re-add any subscriptions to refresh as the subscriptions are at the article level and simply adding the article does not add it to the subscriber.

    Once you've added the articles and subscription, generate a new snapshot. This will include ONLY the changes you have made to the publication.

  • Ratheesh.K.Nair (4/14/2011)


    Hi,

    How to had more tahn 100 tables to an existing replication?

    Now i am using sp_addarticle for each table. Is ther any other way?

    TIA

    So many articles! Can you explain for what purpose it is being replicated? May be then we can help you in a better way!

  • I would suggest to use the system stored procedure sp_addarticle and sp_addsubscription to add your tables to your replication. You can put your 100 or more table names to a string separated each name by a comma and then write a WHILE loop to build the SQL statements to add those tables.

    --------------------------------------------------------------
    DBA or SQL Programmer? Who Knows. :unsure:

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply