Use AdventureWorks;
GO
--Turn on CDC functionality for a database
EXEC sys.sp_cdc_enable_db;
GO
The--is_cdc_enabled field is 1 to enable CDC functionality.
SELECT name, is_cdc_enabled
From sys.databases WHERE database_id = db_id ();
Use AdventureWorks;
GO
--Opening the CDC function of a single sheet
EXECUTE sys.sp_cdc_enable_table
@source_schema = N ' HumanResources '
, @source_name = N ' Employee '
, @role_name = N ' Cdc_admin '
, @capture_instance = N ' Humanresources_employee '
, @supports_net_changes = 1;
--Check if the table has CDC enabled
SELECT [name], IS_TRACKED_BY_CDC from Sys.tables
WHERE [object_id] = object_id (N ' HumanResources. Employee ');
--alternatively, use the built-in CDC help procedure
EXECUTE sys.sp_cdc_help_change_data_capture
@source_schema = N ' HumanResources ',
@source_name = N ' Employee ';
GO
CDC->> turn on CDC functionality in a SQL Server