Technology Encyclopedia Home >How to enable or disable change data capture (CDC) in TencentDB for SQL Server?

How to enable or disable change data capture (CDC) in TencentDB for SQL Server?

To enable or disable Change Data Capture (CDC) in TencentDB for SQL Server, follow these steps:

Enabling CDC

  1. Connect to your TencentDB for SQL Server instance using SQL Server Management Studio (SSMS) or a similar tool.
  2. Execute the following T-SQL command to enable CDC at the database level:
    USE YourDatabaseName;  
    GO  
    EXEC sys.sp_cdc_enable_db;  
    GO  
    
  3. To enable CDC for specific tables, run:
    USE YourDatabaseName;  
    GO  
    EXEC sys.sp_cdc_enable_table  
        @source_schema = N'dbo',  
        @source_name = N'YourTableName',  
        @role_name = NULL;  
    GO  
    

Disabling CDC

  1. To disable CDC for a specific table:
    USE YourDatabaseName;  
    GO  
    EXEC sys.sp_cdc_disable_table  
        @source_schema = N'dbo',  
        @source_name = N'YourTableName',  
        @capture_instance = N'dbo_YourTableName';  
    GO  
    
  2. To disable CDC at the database level:
    USE YourDatabaseName;  
    GO  
    EXEC sys.sp_cdc_disable_db;  
    GO  
    

Tencent Cloud Recommendation

For managed SQL Server CDC, TencentDB provides automated backups and monitoring. Use TencentDB for SQL Server with Cloud Monitor to track CDC performance and ensure data consistency. If you need scalable storage for captured data, consider Tencent Cloud Object Storage (COS) for long-term retention.