forked from mtikoian/SQLDBA-SSMS-Solution
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path6 - Remove Replication.sql
31 lines (24 loc) · 1.05 KB
/
6 - Remove Replication.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms152757(v=sql.105)
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms188734(v=sql.105)
*/
-- Verify Server Name 1st
SELECT @@SERVERNAME as srvName
GO
sp_dropdistributiondb 'distribution'
-- Step 01 - Script out Publication from Publication Server
-- Replication > Local Publications > [PubDatabase]: PubName > Right Click > Generate Scripts..
-- Step 02 - Execute below query on Subscriber Server.
-- This removes replication from subscriber database
USE <<SubscriberDatabase>>
EXEC sp_removedbreplication
GO
-- Step 03 - Delete publication from Publisher server
-- Replication > Local Publications > [PubDatabase]: PubName > Right Click > Delete
-- Execute below query to make sure publication is removed.
USE <<PublicationDatabase>>
EXEC sp_removedbreplication
GO
-- Step 04 - Make sure all the replication jobs get removed with above step
-- Log Reader agent job on Distributor server
-- Distribution agent job on Distributor(push)/Subscriber(pull) server