Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

sys.fn_cdc_decrement_lsn (Transact-SQL)


Applies To: SQL Server 2014, SQL Server 2016 Preview

Returns the previous log sequence number (LSN) in the sequence based upon the specified LSN.

Applies to: SQL Server (SQL Server 2008 through current version).

Topic link icon Transact-SQL Syntax Conventions

sys.fn_cdc_decrement_lsn ( lsn_value )


LSN value. lsn_value is binary(10).


The LSN returned by the function is always less than the specified value, and no LSN values can exist between the two values.

Requires membership in the public database role.

The following example uses sys.fn_cdc_decrement_lsn to set the upper LSN boundary in a query that returns change data rows that have LSN values less than the maximum LSN value.

Use AdventureWorks2012;
DECLARE @from_lsn binary(10), @to_lsn binary(10);
SET @from_lsn = sys.fn_cdc_get_min_lsn('HumanResources_Employee');
SET @to_lsn = sys.fn_cdc_decrement_lsn(sys.fn_cdc_get_max_lsn());
SELECT * FROM cdc.fn_cdc_get_all_changes_HumanResources_Employee( @from_lsn, @to_lsn, 'all'); 
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft