Before getting into the several intricacies of the Microsoft SQL Server Change Data Capture (CDC), its evolution, functions, and types, it is necessary to understand the concept behind Change Data Capture as a standalone entity. 

What is Change Data Capture

Change Data Capture (CDC) is a software pattern used in databases to identify and monitor changes made to them. The types of changes that can be tracked are data update, delete, and insert. These changes are then sent to downstream databases and systems so that the data consistency and synchronization can be maintained across the entire network platform. 

The purpose of Change Data Capture is to capture and transfer changes made at the source database to a target database. The plus point of CDC is that it captures only the changed records which can be identified through triggers, transaction logs, and query-based methods. 

Benefits of Change Data Capture

There are several benefits of the Change Data Capture technology. The most important is real-time data integration where target databases are always synchronized with source databases. Next, by only capturing changes made to a database, data processing time is significantly reduced. Finally, the CDC helps to maintain data integrity and consistency across multiple systems.

Evolution Of Microsoft SQL Server CDC

It had been a long-standing effort to devise processes where changes to a database do not compromise data safety norms and their values and history. Several methods had been tried in the past to set in place optimized data storage settings including changes. These included data auditing, intricate queries, triggers, and date stamps. However, none of these efforts met with the desired results until Microsoft came up with its version of the SQL Server Change Data Capture in 2005. 

Initially, it was not all smooth sailing for SQL Server CDC. Even though the launch version had “after update”, “after insert”, and “after delete” options, DBAs found it too intrusive and difficult to work with. Microsoft was quick to act on this feedback and in 2008, introduced a completely revamped version of the SQL Server Change Data Capture. 

This met with great success as it addressed all the concerns of DBAs in the previous version. It was so successful that to date, Microsoft has kept the main software as it was then. 

The Functioning of SQL Server Change Data Capture

The goal of SQL Server Change Data Capture is to record changes like update, insert, and delete in the source system which are then offered to users in a simple relational format. The process is made easy as the tools needed to capture the data changes such as column information and metadata are built into the changed and modified rows.

After the changes made to the source database are captured and recorded, they are now replicated in the target database under the column information. However, access to the changes recorded by SQL Server Change Data Capture is strictly restricted through table-valued functions to ensure data safety and security. 

What does SQL CDC have to offer that makes it a leader in this niche?

For example, other technologies require users to refresh the source tables continuously to identify any changes and record them in the target databases. This is not only a complex process but also very time-consuming. The SQL Server Change Data Capture, on the other hand, provides unbroken data about the changes made which can be applied to tables and applications when a need arises. 

One such instance of this process is the ETL (Extract, Transform, and Load) application. Here, changes made to data at source as well as incremental data are moved from the source tables to a data mart or a data warehouse. 

SQL Server Change Data Capture monitors all changes made by users in tables and stores them in relational tables. The changes can be accessed and retrieved when required through T-SQL. The CDC feature automatically triggers a replicated image of a table when its functions are applied to a database table. 

There are additional columns of metadata in the replicated tables that verify if changes have been made to the database rows. This is the only difference between the source database and the replicated tables whose architecture is otherwise like the source in all respects. This similarity allows DBAs to use the features of the SQL Server CDC to track the logged tables and gain access to the new audit tables.  

There is another aspect where this CDC technology is beneficial and it is that the source of the changes is mirrored in the transaction log. Hence, any change made in the tracked source tables is immediately noted in the transaction log. The details of the change are linked to the change data section of the original source table.   

Types of SQL Server Change Data Capture

Log-based CDC

In this method of SQL Server Change Data Capture, the transaction log first checks all changes made to the source databases and then transfers them to the target database and system. There is no possibility here of any change missing out in the process. Further, there is no need to change the schemas of the production tables or add new tables. 

The downside is that this method is only compatible with databases that support log-based CDC.  

Trigger-based CDC 

This form of SQL Server CDC has triggers placed in the database that are automatically triggered whenever a change takes place. Among the benefits is that along with low costs of data extraction, it can be easily implemented with details of all transactions found in the shadow tables. 

The downside is an increase in database running costs as additional runtime is required whenever a database is refreshed.