How to Stop and Start SQL DB replications RRS feed

  • Question

  • How do I stop and start a DB publication and then reinitialize the replication using a powershell script. New to PS and SQL need to identify how I parameterize it as well.

    Priyantha Perera

    Tuesday, December 8, 2015 11:23 PM


  • Hi Pri Perera,

    First, based on my search, we can’t stop and start a database publication using PowerShell , however, you can use the following T-SQL statement  to start and stop your publication agent job.

    USE msdb
    EXEC sp_start_job  @job_name = 'publication job name'
    USE msdb
    EXEC sp_stop_job  @job_name = 'publication job name'

    Besides, you can also stop and start a publication following these steps in GUI.
    1.Connect to the Publisher in SQL Server Management Studio (SSMS), and then expand the replication folder.
    2.Expand the Local Publications folder, and then right-click a publication.
    3.Click View Snapshot Agent Status or View Log Reader Agent Status.
    4.Click Start or Stop.

    Second, you can reinitialize subscriptions by setting  parameter “ forceReInit -eq $true” in PowerShell script, for details about how to use PowerShell  to reinitialize subscriptions, please refer to this link

    Ice Fan 

    If you have any feedback on our support, please click here.

    Ice Fan
    TechNet Community Support

    Wednesday, December 9, 2015 11:29 AM