Applies To: SQL Server 2014, SQL Server 2016 Preview
Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Indicates whether a captured column has been updated by checking whether its ordinal position is set within a provided bitmask.
Applies to: SQL Server (SQL Server 2008 through current version).
This function is typically used as part of a change data query to indicate whether a column has changed. In this scenario, the function sys.fn_cdc_get_column_ordinal is used before the query to obtain the required column ordinal. sys.fn_cdc_is_bit_set is then applied to each row of change data that is returned, providing the column-specific information as part of the returned result set.
We recommend using this function instead of the function sys.fn_cdc_has_column_changed when determining whether columns have changed for all rows of a returned result set.
The following example uses sys.fn_cdc_is_bit_set to prepend to the result set generated by the query function cdc.fn_cdc_get_all_changes_HR_Department the column 'IsGroupNmUpdated' using the precomputed column ordinal and the value of __$update_mask as arguments to the call.
USE AdventureWorks2012; GO DECLARE @from_lsn binary(10), @to_lsn binary(10), @GroupNm_ordinal int; SET @from_lsn = sys.fn_cdc_get_min_lsn('HR_Department'); SET @to_lsn = sys.fn_cdc_get_max_lsn(); SET @GroupNm_ordinal = sys.fn_cdc_get_column_ordinal('HR_Department','GroupName'); SELECT sys.fn_cdc_is_bit_set(@GroupNm_ordinal,__$update_mask) as 'IsGroupNmUpdated', * FROM cdc.fn_cdc_get_all_changes_HR_Department( @from_lsn, @to_lsn, 'all') WHERE __$operation = 4; GO