Skip to content

Latest commit

 

History

History
73 lines (52 loc) · 2.81 KB

sys-sp-cdc-enable-db-transact-sql.md

File metadata and controls

73 lines (52 loc) · 2.81 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sys.sp_cdc_enable_db (Transact-SQL)
Enables change data capture for the current database.
markingmyname
maghan
randolphwest
06/13/2023
sql
system-objects
reference
sp_cdc_enable_db_TSQL
sp_cdc_enable_db
sys.sp_cdc_enable_db
sys.sp_cdc_enable_db_TSQL
sys.sp_cdc_enable_db
change data capture [SQL Server], enabling databases
sp_cdc_enable_db
TSQL

sys.sp_cdc_enable_db (Transact-SQL)

[!INCLUDE SQL Server]

Enables change data capture for the current database. This procedure must be executed for a database before any tables can be enabled for change data capture (CDC) in that database. Change data capture records insert, update, and delete activity applied to enabled tables, making the details of the changes available in an easily consumed relational format. Column information that mirrors the column structure of a tracked source table is captured for the modified rows, along with the metadata needed to apply the changes to a target environment.

Important

Change data capture isn't available in every edition of [!INCLUDE ssNoVersion]. For a list of features that are supported by the editions of [!INCLUDE ssNoVersion], see Editions and supported features of SQL Server 2022.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

sys.sp_cdc_enable_db
[ ; ]

Return code values

0 (success) or 1 (failure).

Result set

None.

Remarks

Change data capture can't be enabled on system databases or distribution databases.

sys.sp_cdc_enable_db creates the change data capture objects that have database wide scope, including metadata tables and DDL triggers. It also creates the CDC schema and CDC database user and sets the is_cdc_enabled column for the database entry in the sys.databases catalog view to 1.

Permissions

Requires membership in the sysadmin fixed server role for Change Data Capture on Azure SQL Managed Instance or SQL Server. Requires membership in the db_owner for Change Data Capture on Azure SQL Database.

Examples

The following example enables change data capture.

USE AdventureWorks2022;
GO

EXECUTE sys.sp_cdc_enable_db;
GO

Related content