|
Este artículo se tradujo de forma manual. Mueva el puntero sobre las frases del artículo para ver el texto original.
|
Traducción
Original
|
sys.fn_cdc_get_min_lsn (Transact-SQL)
A.Devolver el valor LSN mínimo para una instancia de captura especificada
USE AdventureWorks2-12;
GO
SELECT sys.fn_cdc_get_min_lsn ('HumanResources_Employee')AS min_lsn;
B.Comprobar el extremo inferior de un rango de consulta
USE AdventureWorks2012;
GO
DECLARE @min_lsn binary(10), @from_lsn binary(10),@save_to_lsn binary(10), @to_lsn binary(10);
-- Sets @save_to_lsn to the previous high endpoint saved from the last change data request.
SET @save_to_lsn = 0x000000000000000000;
-- Sets the upper endpoint for the query range to the current maximum LSN.
SET @to_lsn = sys.fn_cdc_get_max_lsn();
-- Sets the @min_lsn parameter to the current minimum LSN for the capture instance.
SET @min_lsn = sys.fn_cdc_get_min_lsn ('HumanResources_Employee');
-- Sets the low endpoint for the query range to the LSN that follows the previous high endpoint.
SET @from_lsn = sys.fn_cdc_increment_lsn(@save_to_lsn);
-- Tests to verify the low endpoint is valid for the current capture instance.
IF (@from_lsn < @min_lsn)
BEGIN
RAISERROR('Low endpoint of the request interval is invalid.', 16, -1);
END
ELSE
-- Return the changes occurring within the query range.
SELECT * FROM cdc.fn_cdc_get_all_changes_HumanResources_Employee(@from_lsn, @to_lsn, 'all');
GO
