Skip to main content

Usage example

The following SQL statement returns a range of changes from the last handled event (of change sequence "20240723144522110000000000000901203") until the event committed on 23-Jul-2024 at 23:00:00.00. For update operations, the before image value (in this example, the salary before and after) is also returned.

SELECT CHANGE.[header__change_seq],

CHANGE.[header__stream_position],

CHANGE.[header__operation],

CHANGE.[header__transaction_id],

CHANGE.[header__timestamp],

CHANGE.[EMPLOYEE_ID],

CHANGE.[FIRST_NAME],

CHANGE.[LAST_NAME],

CHANGE.[SALARY],

BI.[SALARY],

FROM [Replication].[HR].[EMPLOYEES_ct] CHANGE LEFT OUTER JOIN

[Replication].[HR].[EMPLOYEES_ct] BI  ON

BI.[header__change_seq] = CHANGE.[header$__change_seq] AND

BI.[header__change_oper] = 'B'

WHERE CHANGE.header__oper <> 'B' AND

CHANGE.[header__stream_position] > '20120723144522110000000000000901203' AND

CHANGE.[header__stream_position] <= '2012072323000000Z' AND

ORDER BY

CHANGE.[header__stream_position], CHANGE.[header$__stream_oper]

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!