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.
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 ]
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.