sys.sp_flush_commit_table_on_demand (Transact-SQL)

适用范围:SQL Server

syscommittab 批处理中删除行。

Transact-SQL 语法约定

语法

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

参数

[ @numrows = ] numrows

指定要从 syscommittab 中删除的行数。 @numrows大,不能 NULL

[ @deleted_rows = ] deleted_rows OUTPUT

@deleted_rows是 bigint 类型的 OUTPUT 参数。

[ @date_cleanedup = ] date_cleanedup OUTPUT

@date_cleanedup是 datetime 类型的 OUTPUT 参数。

[ @cleanup_ts = ] cleanup_ts OUTPUT

@cleanup_ts是 bigint 类型的 OUTPUT 参数。

返回代码值

0(成功)或 1(失败)。

示例

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

结果集如下。

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

注解

此过程必须在启用了更改跟踪的数据库中运行。

权限

只有 sysadmin 服务器角色或db_owner数据库角色的成员才能执行此过程。