| title | Clean Up Merge Metadata (Replication Transact-SQL Programming) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 03/03/2017 | ||
| ms.prod | sql | ||
| ms.prod_service | database-engine | ||
| ms.reviewer | |||
| ms.technology | replication | ||
| ms.topic | conceptual | ||
| dev_langs |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | 9b88baea-b7c6-4e5d-88f9-93d6a0ff0368 | ||
| author | MashaMSFT | ||
| ms.author | mathoma | ||
| manager | craigg |
[!INCLUDEappliesto-ss-xxxx-xxxx-xxx-md] Merge replication metadata is cleaned up periodically by the Merge Agent based on the retention setting for the publication. This occurs at the Publisher and Subscriber in the MSmerge_genhistory, MSmerge_contents, MSmerge_tombstone, MSmerge_past_partition_mappings, and MSmerge_current_partition_mappings system tables. You can also programmatically clean up the data in these tables using replication stored procedures.
-
At the Publisher on the publication database, execute sp_mergemetadataretentioncleanup.
-
(Optional) Note the number of rows removed in step 1 from the MSmerge_genhistory, MSmerge_contents, and MSmerge_tombstone system tables, returned respectively in the @num_genhistory_rows, @num_contents_rows, and @num_tombstone_rows output parameters.
-
Repeat steps 1 and 2 at the Subscriber to clean up metadata on the subscription database.