Skip to content

Latest commit

 

History

History
81 lines (66 loc) · 2.96 KB

File metadata and controls

81 lines (66 loc) · 2.96 KB
title sys.fn_cdc_decrement_lsn (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 03/14/2017
ms.prod sql-non-specified
ms.reviewer
ms.suite
ms.technology
database-engine
ms.tgt_pltfrm
ms.topic language-reference
applies_to
SQL Server (starting with 2008)
f1_keywords
fn_cdc_decrement_lsn
sys.fn_cdc_decrement_lsn_TSQL
sys.fn_cdc_decrement_lsn
fn_cdc_decrement_lsn_TSQL
dev_langs
TSQL
helpviewer_keywords
fn_cdc_decrement_lsn
sys.fn_cdc_decrement_lsn
ms.assetid 83c182ad-4713-439b-8769-9b7408aec8b4
caps.latest.revision 18
author BYHAM
ms.author rickbyh
manager jhubbard

sys.fn_cdc_decrement_lsn (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-xxxx-xxxx-xxx_md]

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

Applies to: [!INCLUDEssNoVersion] ([!INCLUDEssKatmai] through current version).

Topic link icon Transact-SQL Syntax Conventions

Syntax

  
sys.fn_cdc_decrement_lsn ( lsn_value )  

Arguments

lsn_value
LSN value. lsn_value is binary(10).

Return Type

binary(10)

Remarks

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

Permissions

Requires membership in the public database role.

Examples

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;  
GO  
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');   
GO  

See Also

sys.fn_cdc_increment_lsn (Transact-SQL)
sys.fn_cdc_get_min_lsn (Transact-SQL)
sys.fn_cdc_get_max_lsn (Transact-SQL)
The Transaction Log (SQL Server)
About Change Data Capture (SQL Server)