Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 2.39 KB

clean-up-merge-metadata-replication-transact-sql-programming.md

File metadata and controls

32 lines (26 loc) · 2.39 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic ms.custom helpviewer_keywords dev_langs
Clean up Merge metadata (Replication SP)
Progrommatically clean up data in the Merge replication tables using replication stored procedures
MashaMSFT
mathoma
09/25/2024
sql
replication
how-to
updatefrequency5
metadata [SQL Server replication]
sp_mergemetadataretentioncleanup
TSQL

Clean Up Merge Metadata (Replication Transact-SQL Programming)

[!INCLUDE SQL Server] 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.

To manually clean up merge metadata

  1. At the Publisher on the publication database, execute sp_mergemetadataretentioncleanup.

  2. (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.

  3. Repeat steps 1 and 2 at the Subscriber to clean up metadata on the subscription database.

Related content