Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

sp_mergemetadataretentioncleanup (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Performs a manual cleanup of metadata in the MSmerge_genhistory, MSmerge_contents, MSmerge_tombstone, MSmerge_past_partition_mappings, and MSmerge_current_partition_mappings system tables. This stored procedure is executed at each Publisher and Subscriber in the topology.

Topic link icon Transact-SQL Syntax Conventions

sp_mergemetadataretentioncleanup [ [ @num_genhistory_rows = ] num_genhistory_rows OUTPUT ]
    [ , [ @num_contents_rows = ] num_contents_rows OUTPUT ] 
    [ , [ @num_tombstone_rows = ] num_tombstone_rows OUTPUT ] 
    [ , [ @aggressive_cleanup_only = ] aggressive_cleanup_only ]

[ @num_genhistory_rows= ] num_genhistory_rows OUTPUT

Returns the number of rows cleaned-up from the MSmerge_genhistory table. num_genhistory_rows is int, with a default of 0.

[ @num_contents_rows= ] num_contents_rows OUTPUT

Returns the number of rows cleaned-up from the MSmerge_contents table. num_contents_rows is int, with a default of 0.

[ @num_tombstone_rows= ] num_tombstone_rows OUTPUT

Returns the number of rows cleaned-up from the MSmerge_tombstone table. num_tombstone_rows is int, with a default of 0.

[ @aggressive_cleanup_only= ] aggressive_cleanup_only

Internal use only.

0 (success) or 1 (failure)

Important note Important

If there are multiple publications on a database, and any one of those publications uses an infinite publication retention period, running sp_mergemetadataretentioncleanup does not clean up the merge replication change tracking metadata for the database. For this reason, use infinite publication retention with caution. To determine if a publication has an infinite retention period, execute sp_helpmergepublication (Transact-SQL) at the Publisher and note any publications in the result set with a value of 0 for retention.

Only members of the db_owner fixed database role or users in the publication access list for a published database can execute sp_mergemetadataretentioncleanup.

Community Additions

ADD
Show:
© 2015 Microsoft