sys.sp_cdc_get_captured_columns (Transact-SQL)

 

Returns change data capture metadata information for the captured source columns tracked by the specified capture instance. Change data capture is not available in every edition of MicrosoftSQL Server. For a list of features that are supported by the editions of SQL Server, see Features Supported by the Editions of SQL Server 2016.

Applies to: SQL Server (SQL Server 2008 through current version).

Topic link icon Transact-SQL Syntax Conventions

  
sys.sp_cdc_get_captured_columns   
    [ @capture_instance = ] 'capture_instance'  

[ @capture_instance = ] 'capture_instance'
Is the name of the capture instance associated with a source table. capture_instance is sysname and cannot be NULL.

To report on the capture instances for the table, run the sys.sp_cdc_help_change_data_capture stored procedure.

0 (success) or 1 (failure)

Column nameData typeDescription
source_schemasysnameName of the source table schema.
source_tablesysnameName of the source table.
capture_instancesysnameName of the capture instance.
column_namesysnameName of the captured source column.
column_idintID of the column in the source table.
ordinal_positionintPosition of the column within the source table.
data_typesysnameColumn data type.
character_maximum_lengthintMaximum character length of the character-based column; otherwise, NULL.
numeric_precisiontinyintPrecision of the column if numeric-based; otherwise, NULL.
numeric_precision_radixsmallintPrecision radix of the column if numeric-based; otherwise, NULL.
numeric_scaleintScale of the column if numeric-based; otherwise, NULL.
datetime_precisionsmallintPrecision of the column if datetime-based; otherwise, NULL.

Use sys.sp_cdc_get_captured_columns to obtain column information about the captured columns returned by querying the capture instance query functions cdc.fn_cdc_get_all_changes_<capture_instance> or cdc.fn_cdc_get_net_changes_<capture_instance>. The column names, IDs, and position remain constant for the life of the capture instance. Only the column data type changes when the data type of the underlying source column in the tracked table changes. Columns that are added to or dropped from a source table have no impact on the captured columns of existing capture instances.

Use sys.sp_cdc_get_ddl_history to obtain information about data definition language (DDL) statements applied to a source table. Any DDL changes that modified the structure of a tracked source column is returned in the result set.

Requires membership in the db_owner fixed database role. For all other users, requires SELECT permission on all captured columns in the source table and, if a gating role for the capture instance was defined, membership in that database role. When the caller does not have permission to view the source data, the function returns error 22981 (Object does not exist or access is denied.).

The following example returns information about the captured columns in the HumanResources_Employee capture instance.

USE AdventureWorks2012;  
GO  
EXECUTE sys.sp_cdc_get_captured_columns   
    @capture_instance = N'HumanResources_Employee';  
GO  

sys.sp_cdc_help_change_data_capture (Transact-SQL)

Community Additions

ADD
Show: