sys.fn_cdc_increment_lsn (Transact-SQL)
Returns the next log sequence number (LSN) in the sequence based upon the specified LSN.
Transact-SQL Syntax Conventions
Składnia
sys.fn_cdc_increment_lsn ( lsn_value )
Arguments
- lsn_value
LSN value. lsn_value is binary(10).
Return Type
binary(10)
Uwagi
The LSN value returned by the function is always greater than the specified value, and no LSN values exist between the two values.
To systematically query a stream of change data over time, you can repeat the query function call periodically, each time specifying a new query interval to bound the changes returned in the query. To help insure that no data is lost, the upper bound for the previous query is often used to generate the lower bound for the subsequent query. Because the query interval is a closed interval, the new lower bound must be larger than the previous upper bound, but small enough to ensure no changes have LSN values that lie between this value and the old upper bound. The function sys.fn_cdc_increment_lsn is used to obtain this value.
Permissions
Requires membership in the public database role.
Examples
The following example uses sys.fn_cdc_increment_lsn to generate a new lower bound value for a change data capture query based on the upper bound saved from a previous query and saved in the variable @save\_to\_lsn.
USE AdventureWorks2012;
GO
DECLARE @from_lsn binary(10), @to_lsn binary(10), @save_to_lsn binary(10);
SET @save_to_lsn = <previous_upper_bound_value>;
SET @from_lsn = sys.fn_cdc_increment_lsn(@save_to_lsn);
SET @to_lsn = sys.fn_cdc_get_max_lsn();
SELECT * from cdc.fn_cdc_get_all_changes_HumanResources_Employee( @from_lsn, @to_lsn, 'all' );
GO
Zobacz także
Odwołanie
sys.fn_cdc_decrement_lsn (Transact-SQL)
cdc.fn_cdc_get_all_changes_<capture_instance> (Transact-SQL)
cdc.fn_cdc_get_net_changes_<capture_instance> (Transact-SQL)