What's new

Welcome to roeaw | Welcome My Forum

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

A Deep Dive Into CDC With Azure Information Manufacturing facility


Staff member
Mar 22, 2024
Reaction score
Change Information Seize (CDC) in SQL Server is a robust characteristic designed to trace and seize modifications made to knowledge inside a database. It offers a dependable and environment friendly technique to establish alterations to tables, permitting for the extraction of invaluable insights into knowledge modifications over time. By enabling CDC with Azure Data Factory, SQL Server allows a scientific and automatic method to monitoring and capturing modifications, facilitating higher knowledge administration, auditing, and evaluation throughout the database surroundings.

Most Widespread Use-Circumstances: CDC With Azure Information Manufacturing facility​

Widespread situations the place the CDC with Azure Information Manufacturing facility proves useful embrace:

Audit Path and Analytics: Monitoring knowledge alterations for audit trails and conducting analytical assessments on change knowledge.

Downstream Propagation: Effectively propagating modifications to downstream subscribers for synchronized knowledge updates.

ETL Operations: Facilitating Extract, Remodel, Load (ETL) operations to seamlessly switch knowledge modifications from the On-line Transaction Processing (OLTP) system to an information lake or knowledge warehouse. Instruments like Azure Information Manufacturing facility could be employed for this goal.

Occasion-Pushed Programming: Enabling event-based programming for instantaneous responses triggered by knowledge modifications, enhancing real-time system interactions.

Utilization: Some Queries​

Listed below are SQL queries and instructions for managing Change Information Seize (CDC) in SQL Server:

  • Verify if CDC is enabled for the database:

Choose identify, is_cdc_enabled from sys.databases;

  • Verify which tables have CDC enabled::

Choose identify, is_tracked_by_cdc from sys.tables;

  • First, the database must be enabled:
    • EXEC sys.sp_cdc_enable_db
  • Then allow all of the tables to be audited:

EXECUTE sys.sp_cdc_enable_table

@source_schema = N’dbo’,

@source_name = N’PslMaterials’,

@role_name = NULL;

  • To disable the database:
    • EXEC sys.sp_cdc_disable_db
  • To disable a desk:
    • EXEC sys.sp_cdc_disable_table
    • @source_schema = N’dbo’,
    • @source_name = N’MyTable’,
    • @capture_instance = N’dbo_MyTable’

When CDC is enabled for a database, a devoted schema named CDC is established. Inside this schema, a number of important tables are created to handle and retailer change knowledge. It’s essential to notice that disabling CDC for a desk or the complete database can result in the elimination of those tables, ensuing within the lack of historic modifications. To protect this historic knowledge, it’s needed to repeat the modifications to a different desk or file.

CDC Schema​

The important thing tables throughout the CDC schema embrace:

  • cdc.change_tables: the checklist of tables with cdc enabled
  • cdc.captured_columns : the checklist of captured columns for every desk
  • cdc.ddl_history: Paperwork Information Definition Language (DDL) statements that modify the supply tables. These modifications aren’t instantly utilized to CDC tables; a restart of the CDC occasion is required for the modifications to take impact.
  • cdc.index_columns: Defines the first key of CDC tables.
  • cdc.lsn_time_mapping: Manages lengthy block sequence quantity time mapping.

Moreover, when a desk is enabled for CDC, two extra tables are created:

  • cdc.cdc_jobs: Handles CDC-related jobs.
  • cdc.SchemaName_TableName_CT: Represents the change desk for a selected schema and desk, for example, dbo_PslVendors_CT.

Mirrors all fields from the unique desk with some further columns wanted for CDC:

  • __$start_lsn: Binary code that retains observe of when modifications have been dedicated, serving to preserve the order by which modifications occurred.
  • __$seqval: One other binary code used to prepare modifications to a row inside a transaction.
  • __$operation: A quantity indicating the kind of change made to the info. 1 represents a deletion, 2 is for insertion, and three and 4 are for updates (capturing column values earlier than and after the replace).
  • __$update_mask: A collection of bits indicating which columns have been modified throughout an replace.
  • <captured supply desk columns>: The remaining columns signify the particular knowledge captured throughout the creation of the seize occasion. If no columns have been specified, all columns from the supply desk are included.

CDC Implementation Particulars:

  • Each supply desk enabled for the CDC has its devoted CDC desk.
  • Guarantee adequate database house to accommodate the extra tables generated, stopping potential house shortages.
  • The SQL Server Agent seize job retrieves modifications from the transaction log and incorporates them into the corresponding change tables.
  • Cleanup jobs handle the change tables, adhering to a retention coverage to take away outdated knowledge.
  • Question features present a method to entry and make the most of change knowledge from the CDC change tables.
  • In Azure SQL databases, the place SQL Server Agent is unavailable, the CDC scheduler assumes the position of capturing and cleansing up knowledge.

Efficiency Concerns: Elements Impacting Efficiency​

  • Variety of CDC-Enabled Tables
    • The extra tables enabled for CDC, the upper the processing overhead. Consider necessity in opposition to efficiency influence.
  • Frequency of Modifications in Tracked Tables
    • Tables present process frequent modifications enhance the amount of captured knowledge. Repeatedly altering knowledge could influence efficiency.
  • Area Availability within the Supply Database
    • CDC captures modifications and shops them. Guarantee enough house within the supply database to accommodate change tables with out risking house shortages.
CTA Software

CDC with Azure Information Manufacturing facility​

In Azure cloud, Information Manufacturing facility is a robust software for numerous wants, and now features a preview for Change Information Seize (CDC), which simplifies the method, providing the seamless energy of CDC. Let’s discover the steps to leverage this characteristic:

Step to create CDC in Information manufacturing unit:

1. Let’s create a CDC: CDC could be executed as a standalone useful resource, eliminating the necessity for a pipeline as it’s wanted for instance for working Information flows.

new Cdc

2. Assign a reputation to the useful resource (it have to be alphanumeric): Select the supply sort, starting from numerous sorts of databases to recordsdata. Within the case of Azure SQL database, choose the tables. CDC-enabled tables are routinely detected; in any other case, specify a subject defining row modifications (usually a modified date subject).

create cdc v2

3. Select the vacation spot: On this case, the identical because the origin sorts: databases and in addition some storage the place to retailer the recordsdata with the modifications.

create cdc destination

4. Outline the vacation spot: The vacation spot desk shall be created routinely with the Auto map possibility chosen. Select a key for the vacation spot desk.

new mapping

5. Outline a latency among the many given choices: Actual-time, 15-minute, 30-minute, 1 hour, 2 hours. Provoke the method, and the agent will learn knowledge at outlined intervals.

6. Monitor: The inexperienced dots signify the cases when CDC was executed, occurring each quarter-hour on this instance. The blue dots signify the captured modifications throughout every execution, offering a transparent monitoring interface.

monitor cdc


CDC stands out as a sturdy and influential software, providing invaluable capabilities for monitoring and managing modifications in databases. With the arrival of CDC with Azure Information Manufacturing facility, this energy is seamlessly harnessed in a user-friendly and sensible method. The mix of CDC and Information Manufacturing facility presents an environment friendly and accessible answer for implementing Change Information Seize with utmost satisfaction.

  • Oriol Saludes

    Skilled Full Stack Engineer with a demonstrated historical past of working within the info expertise and providers trade. Expert in PHP, Spring Boot, Java, Kotlin, Area-Pushed Design (DDD), TDD and Entrance-end Growth. Sturdy engineering skilled with a Engineer’s diploma centered in Laptop Engineering from Universitat Oberta de Catalunya (UOC).

    View all posts

Top Bottom