Re initializing replication after the changes in articles using script

Anitha John 1 Reputation point
2022-07-08T06:58:53.35+00:00

Hi team,

I am using scripts to create Publication, articles and subscriptions using the procedures, sp_addpublication, sp_addpublication_snapshot, sp_addarticle, sp_addsubscription, sp_startpublication_snapshot, sp_addpullsubscription. It is working fine.

Now I should be able to add, remove or update the publication. What are the steps to follow using sql scripts.

Thanks & Regards,
Anitha

Developer technologies Transact-SQL
SQL Server Other
{count} votes

3 answers

Sort by: Most helpful
  1. Bert Zhou-msft 3,436 Reputation points
    2022-07-11T02:59:08.297+00:00

    Hi,@Anitha John

    219307-image.png

    Your needs are vague and we don't know exactly what you want? Do you want to ask about the aspects that need to be paid attention to when using SP stored procedures ? Please read this document in detail.

    Bert Zhou

    0 comments No comments

  2. Anitha John 1 Reputation point
    2022-07-11T05:12:56.65+00:00

    Hi, @Bert Zhou-msft ,

    I have created SQL Server replication transaction with out using SSMS. I used scripts for that.
    My question was how can I re-initiate the subscription when the publication articles changes like adding an extra column in a table or removing table etc. without using SSMS. I tried using sp_reinitsubscription, but I didn't work.
    What are the steps to follow to change an article and reflect that change in the subscriber. (Not using SSMS, but the scripts and steps for that)

    Thanks & Regards,
    Anitha

    0 comments No comments

  3. Seeya Xi-MSFT 16,586 Reputation points
    2022-07-11T09:29:45.657+00:00

    Hi @Anitha John ,

    Welcome to Microsoft Q&A!
    Please refer to this official document: https://learn.microsoft.com/en-us/sql/relational-databases/replication/reinitialize-a-subscription?view=sql-server-ver16
    This document contains the SSMS approach and the sql script approach.

    I tried using sp_reinitsubscription, but I didn't work.

    Only members of the sysadmin fixed server role, members of the db_owner fixed database role, or the creator of the subscription can execute sp_reinitsubscription. You can check it.

    Best regards,
    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.