About sequencing the CDC data using the __$start_lsn
and __$seqval
columns, the information from the Microsoft documentation stating that __$seqval
should not be used for ordering and to use __$command_id
instead seems to conflict with your actual experience, where using __$start_lsn
and __$seqval
appears to give you the correct sequencing.
Since the Microsoft documentation is not fully aligned with your experience, and you are using a relatively recent version of SQL Server, verifying the behavior of CDC in your specific version and environment might be worthwhile. You can do this by conducting further testing, referring to the official documentation for your exact SQL Server version (if available), or contacting Microsoft support for clarification.
It's also important to keep in mind that accessing system tables directly, as mentioned in the article you referenced, is generally discouraged because the underlying structures might change in future updates, which could lead to issues and incompatibilities. The recommended approach is to use the provided functions like cdc.fn_cdc_get_all_changes_<capture_instance>
and cdc.fn_cdc_get_net_changes_<capture_instance>
to access CDC data.
If you find that using __$start_lsn
and __$seqval
works correctly for sequencing the data in your specific version of SQL Server, it might be a viable solution for your current needs. However, it's always good to be cautious about potential future changes and ensure compatibility with new SQL Server versions.