Bewerken

Delen via


sys.sp_flush_commit_table_on_demand (Transact-SQL)

Applies to: SQL Server

Deletes rows from syscommittab in batches.

Transact-SQL syntax conventions

Syntax

sp_flush_commit_table_on_demand
    [ @numrows = ] numrows
    , [ @deleted_rows = ] deleted_rows OUTPUT
    , [ @date_cleanedup = ] date_cleanedup OUTPUT
    , [ @cleanup_ts = ] cleanup_ts OUTPUT
[ ; ]

Arguments

[ @numrows = ] numrows

Specifies the number of rows you want to delete from syscommittab. @numrows is bigint, and can't be NULL.

[ @deleted_rows = ] deleted_rows OUTPUT

@deleted_rows is an OUTPUT parameter of type bigint.

[ @date_cleanedup = ] date_cleanedup OUTPUT

@date_cleanedup is an OUTPUT parameter of type datetime.

[ @cleanup_ts = ] cleanup_ts OUTPUT

@cleanup_ts is an OUTPUT parameter of type bigint.

Return code values

0 (success) or 1 (failure).

Examples

DECLARE @deleted_rows BIGINT;
DECLARE @date_cleanedup DATETIME;
DECLARE @cleanup_ts BIGINT;

EXEC sys.sp_flush_commit_table_on_demand 3000,
    @deleted_rows = @deleted_rows OUTPUT,
    @date_cleanedup = @date_cleanedup OUTPUT,
    @cleanup_ts = @cleanup_ts OUTPUT;

PRINT CONCAT ('Number of rows deleted: ', @deleted_rows);
PRINT CONCAT ('Cleanup date: ', @date_cleanedup);
PRINT CONCAT ('Change tracking version: ', @cleanup_ts);
GO

Here's the result set.

Started executing query at Line 1
The value returned by change_tracking_hardened_cleanup_version() is 17.
The value returned by safe_cleanup_version() is 17.
(0 rows affected)
Number of rows deleted: 100
Cleanup date: Aug 29 2022  8:59PM
Change tracking Version: 17
Total execution time: 00:00:02.008

Remarks

This procedure must be run in a database that has change tracking enabled.

Permissions

Only a member of the sysadmin server role or db_owner database role can execute this procedure.