使用範例
下列 SQL 陳述式從上次處理的事件傳回變更範圍 (變更順序「20120723144522110000000000000901203」),直到在 23-Jul-2012 的 23:00:00.00 認可事件為止。對於更新操作,也會傳回之前影像值 (在此範例中,即之前和之後的薪資)。
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
排序依據
CHANGE.[header__stream_position], CHANGE.[header$__stream_oper]