Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 2.61 KB

sp-expired-subscription-cleanup-transact-sql.md

File metadata and controls

58 lines (41 loc) · 2.61 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sp_expired_subscription_cleanup (Transact-SQL)
sp_expired_subscription_cleanup checks the status of all the subscriptions of every publication and drops expired subscriptions.
markingmyname
maghan
randolphwest
07/16/2024
sql
replication
reference
sp_expired_subscription_cleanup
SP_EXPIRED_SUBSCRIPTION_CLEANUP_TSQL
sp_expired_subscription_cleanup
TSQL

sp_expired_subscription_cleanup (Transact-SQL)

[!INCLUDE SQL Server]

Checks the status of all the subscriptions of every publication and drops subscriptions that are expired. This stored procedure is executed at the Publisher on any database, or at the Distributor on the distribution database for a non-[!INCLUDE ssNoVersion] Publisher.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

sp_expired_subscription_cleanup [ [ @publisher = ] N'publisher' ]
[ ; ]

Arguments

[ @publisher = ] N'publisher'

The name of a non-[!INCLUDE ssNoVersion] publisher. @publisher is sysname, with a default of NULL. You shouldn't specify this parameter for a [!INCLUDE ssNoVersion] Publisher.

Return code values

0 (success) or 1 (failure).

Remarks

sp_expired_subscription_cleanup is used in all types of replication.

The Expired Subscription Clean Up job runs sp_expired_subscription_cleanup to detect and remove expired subscriptions from publication databases every 24 hours. If any of the subscriptions are out-of-date, that is, aren't synchronized with the Publisher within the retention period, the publication is declared expired, and the traces of the subscription are cleaned up at the Publisher. For more information, see Subscription Expiration and Deactivation.

Permissions

Only members of the sysadmin fixed server role or db_owner fixed database role can execute sp_expired_subscription_cleanup.

Related content