Attaching a CDC enabled database on SQL Server 2016

When you detach a database with Change Data Capture enabled on SQL Server 2014 and below and attach it to a SQL Server 2016 instance, you could run into the error mentioned below while execute Change Data Capture (CDC) related procedures.

Error:

Msg 22832, Level 16, State 1, Procedure sp_cdc_enable_table_internal, Line 639 [Batch Start Line 0]

Could not update the metadata that indicates table [<schema name>].[<object name>] is enabled for Change Data Capture. The failure occurred when executing the command ‘insert into [cdc].[captured_columns]’. The error returned was 213: ‘Column name or number of supplied values does not match table definition.’. Use the action and error to determine the cause of the failure and resubmit the request.

This is due to the fact that there is a metadata change in SQL Server 2016 associated with Change Data Capture which does not happen till you manually execute sys.sp_cdc_vupgrade against the newly attached database on the SQL Server 2016 instance.

The “Attach a Database” online documentation has also been updated to reflect this information.