Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:01:09+00:00 2026-06-08T10:01:09+00:00

im using sql server 2012 and replication process in it. now the replication process

  • 0

im using sql server 2012 and replication process in it. now the replication process is working correctly, but i want to delete this replication, i mean all the publications, subscriptions and articles through script. i went through this site http://support.microsoft.com/kb/324401 and tried the following script

:setvar PublisherDatabase "AdventureWorks2012"
:setvar SubscriberServer "HYDHTC0131320D\MSSQLSERVER2"

use [$(PublisherDatabase)]

--Drop all subscriptions
exec sp_dropsubscription  
@publication = N'TestPubs',
@article = N'all',
--@subscriber = [$(SubscriberServer)]
@subscriber = N'all',
@destination_db = N'all'

--Drop publication
if exists (Select 1 From SysPublications where name = N'TestPubs')
EXEC sp_droppublication @publication = N'TestPubs'

EXEC sp_replicationdboption @dbname = [$(PublisherDatabase)], @optname = N'publish', @value = N'false'

--Drop subscriber entry
EXEC sp_dropsubscriber @subscriber = [$(SubscriberServer)]

--Drop distributor
EXEC sp_dropdistributor @no_checks = 1

after i execute the above script, im getting the following error.

Only one Log Reader Agent or log-related procedure (sp_repldone, sp_replcmds, and sp_replshowcmds) can connect to a database at a time. If you executed a log-related procedure, drop the connection over which the procedure was executed or execute sp_replflush over that connection before starting the Log Reader Agent or executing another log-related procedure.

Msg 18752, Level 16, State 1, Procedure sp_replcmds, Line 1

Only one Log Reader Agent or log-related procedure (sp_repldone, sp_replcmds, and sp_replshowcmds) can connect to a database at a time. If you executed a log-related procedure, drop the connection over which the procedure was executed or execute sp_replflush over that connection before starting the Log Reader Agent or executing another log-related procedure.

The Subscriber was dropped.

Msg 20015, Level 16, State 1, Procedure 

sp_MSreplremoveuncdir, Line 83
Could not remove directory 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\ReplData\unc\HYDHTC0131320D_ADVENTUREWORKS2012_TESTPUBS\20120719152739\'. Check the security context of xp_cmdshell and close other processes that may be accessing the directory.

check this screenshot for more details

enter image description here

can anyone help me in solving these issues

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:01:10+00:00Added an answer on June 8, 2026 at 10:01 am

    It looks like you had some errors when dropping replication and have some orphaned subscription metadata at teh Subscriber. Orphaned metadata can be removed from the subscription database using sp_removedbreplication.

    For future reference, you can remove all subscriptions, publications, and disable publishing and distribution following these steps:

    • Delete a Push Subscription
    • How to: Delete a Publication
    • Disabling Publishing and Distribution

    Relevant bits of code from the links

    a) To drop a push subscription on transactional replication

    -- This batch is executed at the Publisher to remove 
    -- a pull or push subscription to a transactional publication.
    DECLARE @publication AS sysname;
    DECLARE @subscriber AS sysname;
    SET @publication = N'AdvWorksProductTran';
    SET @subscriber = $(SubServer);
    
    USE [AdventureWorks2012]
    EXEC sp_dropsubscription 
      @publication = @publication, 
      @article = N'all',
      @subscriber = @subscriber;
    GO
    

    b) To drop a subscription on a merge replication

    DECLARE @publication AS sysname;
    DECLARE @subscriber AS sysname;
    DECLARE @subscriptionDB AS sysname;
    SET @publication = N'AdvWorksSalesOrdersMerge';
    SET @subscriber = $(SubServer);
    SET @subscriptionDB = N'AdventureWorks2012Replica';
    
    USE [AdventureWorks2012]
    EXEC sp_dropmergesubscription 
      @publication = @publication, 
      @subscriber = @subscriber, 
      @subscriber_db = @subscriptionDB;
    GO
    

    c) To drop a publication and set a source DB to stop being a publisher, on a transactional replication.

    DECLARE @publicationDB AS sysname;
    DECLARE @publication AS sysname;
    SET @publicationDB = N'AdventureWorks2008R2'; 
    SET @publication = N'AdvWorksProductTran'; 
    
    -- Remove a transactional publication.
    USE [AdventureWorks2008R2]
    EXEC sp_droppublication @publication = @publication;
    
    -- Remove replication objects from the database.
    USE [master]
    EXEC sp_replicationdboption 
      @dbname = @publicationDB, 
      @optname = N'publish', 
      @value = N'false';
    GO
    

    d) To drop a publication and set a source DB to stop being a publisher, on a merge replication.

    DECLARE @publication AS sysname
    DECLARE @publicationDB    AS sysname
    SET @publication = N'AdvWorksSalesOrdersMerge' 
    SET @publicationDB = N'AdventureWorks2008R2'
    
    -- Remove the merge publication.
    USE [AdventureWorks2008R2]
    EXEC sp_dropmergepublication @publication = @publication;
    
    -- Remove replication objects from the database.
    USE master
    EXEC sp_replicationdboption 
      @dbname = @publicationDB, 
      @optname = N'merge publish', 
      @value = N'false'
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using sql server 2012 and its replication feature. Here im trying to manually
I'm using SQL Server 2012 and trying to implement transactional replication. Im using the
Im using sql server 2012 and transactional replication. For replication security, I created a
I am using a JDBC driver for Microsoft SQL Server 2012 (sqljdbc_4.0) and although
We have an issue upgrading to SQL Server 2012. I am using the following
[using SQL Server 2005] I have a table full of users, I want to
I am using SQL Server 2012 RC0 + EF 4 + MVC 4. 90%
I want to insert this XML data into SQL Server 2008 <rewriteMap name=OldStaticUrl> <add
Using SQL Server 2012 Express. I have a table which represents key/value pairs. keycol
Using SQL Server 2000 Table1 Id date --- ---------- 001 23/01/2012 002 25/01/2012 003

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.