SQL Server script to remove replication?

I was asked to write an SQL script that can be run, which will stop replication and remove the subscriber / subscription.

Is it possible? Or do you need to use a graphical interface?

+6
source share
3 answers

What version of SQL Server are you using.

Try

sp_removedbreplication 'DB_PROD' go 

Related reading - How to clear replication bits - http://blogs.msdn.com/b/repltalk/archive/2010/11/17/how-to-cleanup-replication-bits.aspx

Google also provides an MSDN article in the results.

How to disable publishing and distribution (Transact-SQL Programming replication) - http://msdn.microsoft.com/en-us/library/ms147921.aspx

+11
source

SELECT spid FROM sys.sysprocesses WHERE dbid = db_id ('distribution') and use the process number to kill it, as shown below: kill 65

0
source

If you want to completely remove replication, including all the "bits". Or your server has only one publication, and this is the one you are trying to delete.

I would recommend:

  • Connect to the publisher or distributor that you want to disable in Microsoft SQL Server Management Studio, and then expand the node server.
  • Right-click the Replication folder and select Disable Publishing and Distribution.
  • Follow the instructions of the Disable Publishing and Distribution Wizard and select generate scripts instead of processing .

This has the advantage of not only completely cleaning things up. But also deleting the distribution database, which, if you have ever dealt with previously, is known to be dotted with replication residues from the past.

Full documentation can be found here .

0
source

Source: https://habr.com/ru/post/891620/


All Articles