spMFDeleteHistory

Return
  • 1 = Success

  • -1 = Error

Parameters
@DeleteBeforeDate
  • earliest date for retention of logs

@BatchSize
  • Number of rows to delete per batch (default: 2000)

Purpose

The purpose of this procedure is to delete all records in MFlog,MFUpdateHistory,MFAuditHistory till the given date Additional Info ===============

This procedure is built into an agent to run it on a schedule

Examples

EXEC spMFDeleteHistory @DeleteBeforeDate = '2023-11-01';

Run with Default Batch Size (2000 records)


EXEC spMFDeleteHistory @DeleteBeforeDate = '2023-11-01', @BatchSize = 5000;

Run with Custom Batch Size (5000 records per batch)


EXEC spMFDeleteHistory @DeleteBeforeDate = '2023-11-01', @BatchSize = NULL;

Run with Explicit NULL (Defaults to 2000)

EXEC spMFDeleteHistory @DeleteBeforeDate = '2023-11-01', @BatchSize = 5000, @Debug = 1;

Run with debug messages showing (use for agent messages also)

Changelog

Date

Author

Description

2025-01-05

JPE

Added @BatchSize parameter with default value.

Optimized for high-volume databases: batch deletes, reduced locks, error handling, and logging. Added loop reporting for progress tracking.

2020-09-12

LC

Add documentation

2016-11-10

LC

Add ProcessBatch and ProcessBatchDetail to delete