Which column to use for ordering change data read from change tables in SQL Server?

53 Views Asked by At

Should I rely on seqval for ordering change data captured from change tables in SQL Server, documentation provides contradictory statements in two places. If not, is there any option?

If we check cdc.fn_cdc_get_all_changes_<capture_instance>, it says for __$seqval

Sequence value used to order changes to a row within a transaction.

And here in cdc.<capture_instance>_CT, it is mentioned for __$seqval:

Sequence of the operation as represented in the transaction log. Should not be used for ordering. Instead, use the __$command_id column.

I believe both these __$seqval are same as fn_cdc_get_all_changes function reads from cdc.<capture_instance>_CT table. I would have used __$command_id if it was returned from fn_cdc_get_all_changes function as reading from system tables directly is not recommended.

0

There are 0 best solutions below