Adding all articles in T-SQL?

  • I'm looking to automate the publishing of a database, read up on the several sp's on the subject. I stumbled on sp_addarticle. It seems I can only add 1 artivle at the time. Since I have to publish a db with 800+ tables, I considered writing a cursor(shudder!) and get all the usertables from sysobject to publish them.

    In got to think, though. When using EM to publish a database I get the option to SELECT ALL articles. I don't know what happens behind the screen, but could I somehow select all tables for publishing in T-SQL? Or maybe someone already wrote such a script?

    Greetz,
    Hans Brouwer

  • with the sp sp_addarticle you must add each table independently.

    I did it once, because have many tables to add to a publication and create a cursor with the tables I needed. And then did something like this:

    EXEC ('EXEC sp_addArticle @article = '+''''+ @TableName + ''''+ ', ...

    Sorry but don't have the script.

  • Create the publication in EM.

    Once created, right click on the publication and select "Generate SQL Script".

    this will give you a script that you can modify and run using "query analyzer" to recreate the publication.

     

    good luck 


    Don't count what you do, do what counts.

    SQL Draggon

  • 1learns everyday. Tnx for the heads up.

    Greetz,
    Hans Brouwer

Viewing 4 posts - 1 through 3 (of 3 total)

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