Events
Sep 15, 6 AM - Sep 17, 3 PM
The best SQL community-led learning event. Sept 2025. Save €200 with code FABLEARN.
Get registeredThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
Drops a subscription to a merge publication and its associated Merge Agent. This stored procedure is executed at the Publisher on the publication database.
Transact-SQL syntax conventions
sp_dropmergesubscription
[ [ @publication = ] N'publication' ]
[ , [ @subscriber = ] N'subscriber' ]
[ , [ @subscriber_db = ] N'subscriber_db' ]
[ , [ @subscription_type = ] N'subscription_type' ]
[ , [ @ignore_distributor = ] ignore_distributor ]
[ , [ @reserved = ] reserved ]
[ ; ]
The publication name. @publication is sysname, with a default of NULL
. The publication must already exist and conform to the rules for identifiers.
The name of the Subscriber. @subscriber is sysname, with a default of NULL
.
The name of the subscription database. @subscriber_db is sysname, with a default of NULL
.
The type of subscription. @subscription_type is nvarchar(15), and can be one of these values.
Value | Description |
---|---|
all |
Push, pull, and anonymous subscriptions |
anonymous |
Anonymous subscription. |
push |
Push subscription. |
pull |
Pull subscription. |
both (default) |
Both push and pull subscriptions. |
Indicates whether this stored procedure is executed without connecting to the Distributor. @ignore_distributor is bit, with a default of 0
. This parameter can be used to drop a subscription without doing cleanup tasks at the Distributor. It's also useful if you have to reinstall the Distributor.
Reserved for future use. @reserved is bit, with a default of 0
.
0
(success) or 1
(failure).
sp_dropmergesubscription
is used in merge replication.
-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables
-- on the command line and in SQL Server Management Studio, see the
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".
-- This batch is executed at the Publisher to remove
-- a pull or push subscription to a merge publication.
DECLARE @publication AS sysname;
DECLARE @subscriber AS sysname;
DECLARE @subscriptionDB AS sysname;
SET @publication = N'AdvWorksSalesOrdersMerge';
SET @subscriber = $(SubServer);
SET @subscriptionDB = N'AdventureWorks2022Replica';
USE [AdventureWorks2022]
EXEC sp_dropmergesubscription
@publication = @publication,
@subscriber = @subscriber,
@subscriber_db = @subscriptionDB;
GO
Only members of the sysadmin fixed server role or the db_owner fixed database role can execute sp_dropmergesubscription
.
Events
Sep 15, 6 AM - Sep 17, 3 PM
The best SQL community-led learning event. Sept 2025. Save €200 with code FABLEARN.
Get registeredAsk Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in