This post will guide you through all that you need to know about SQL Server CDC (Change Data Capture). It will cover the concept of CDC, the evolution of SQL Server Change Data Capture, the workflow of this technology, and its types.
Change Data Capture, primarily a software pattern, is very critical in today’s data-driven business environment. It is imperative for organizations now to ensure that their data is safe and secure, and hackers do not get access to classified information. This aspect is guaranteed by Change Data Capture, where any changes made to data and their values are stored in a way that does not compromise their state.
Before Microsoft introduced SQL Server CDC, efforts had been made to create a form of Change Data Capture that met the requirements of businesses. These included triggers, timestamps, data auditing, and complex queries, but none could live up to the required expectations. It was not until Microsoft launched its SQL Server CDC that data safety and replication needs were met.
Development of SQL Server CDC
SQL Server CDC was launched by Microsoft in 2005 with several technologically advanced features, such as “after update”, “after insert”, and “after delete” capabilities. Even though it did meet what was required to some extent, DBAs found the technology to be too invasive and cumbersome.
Based on this feedback, Microsoft came up with a revised version of SQL Server CDC in 2008. This method was very popular as developers and DBAs could capture and store changed data without any human intervention. Incidentally, this version from Microsoft is still in use today with only minor changes after almost two decades.
Concept Behind SQL Server Change Data Capture
Basically, SQL Server CDC technology was developed to capture and record changes to data in the source database. The changes, categorized as “Insert”, “Update”, or “Delete”, can be accessed by users quickly and effortlessly as they are available in a simple and easy-to-understand relational format.
CDC provides all information necessary to capture the changed data to an intended target, like column info and metadata for modified and changed rows. These captured changes are stored by SQL Server CDC in tables that mirror the structure of the tracked source tables. Access to these changes is strictly controlled and limited to authorized personnel only through table-valued functions, thereby ensuring high data safety and security.
Among the top beneficiaries of the SQL Server CDC technology is the ETL (Extract, Transform, and Load) application. In this case, all data that has changed in the source tables of the SQL Server is moved incrementally to a target location, such as a data mart or data warehouse, by an ETL application.
Even though others have entered the Change Data Capture niche, it is SQL Server CDC that has always been ahead of the competitors. To know the reason, it is necessary to understand the mode of working of the traditional CDC.
In the past, to reflect any changes made in source tables, the tables had to be refreshed at fixed intervals. This process was not only time-consuming but also increased the costs of operating databases. On the other hand, SQL Server CDC ensures that changes made to the source tables are automatically captured seamlessly and moved to a target location. This has made it a cut above the others.
Workflow of SQL Server Change Data Capture
The workflow of SQL Server CDC is as follows.
# Change Data Capture tracks and monitors all changes made to tables by users that are then stored in relational tables.
# The changes stored in relational tables can be quickly accessed and retrieved with T-SQL.
# Whenever CDC is applied to a source database table, a mirror image of the tracked table is created in all cases.
# The changes made to the database rows are identified by the columns of metadata that are present in the structure of the columns of the replicated tables.
The advantage of using SQL Server CDC is that the structure and all other attributes of the source and the target tables are the same, except for the additional columns of metadata present in the replicated tables. These verify if any changes have been made to the database rows.
Another benefit of SQL Server CDC is that once a task has been completed, new audit tables track and monitor the logged tables where the changes have been registered. These transaction logs show the source of the changes in CDC.
Whenever any changes, such as insert, update, or delete, are noticed in the tracked tables at source, the details of these entries are added to the log, which then becomes an integral part of CDC. The log, having a thorough description of the changes, is then read and added to the change table section of the original table.
Types of SQL Server Change Data Capture
There are two types of SQL Server CDC.
Log-based Change Data Capture
In this form of CDC, the log and file of a database are analyzed by the system to verify whether all changes have been captured before they are replicated to the target database. The benefit here is that in this type of CDC, apart from being very accurate, the schemas of the production tables need not be changed or new tables added. Hence, there is a negligible effect of CDC on the production database system.
Trigger-based Change Data Capture
In this type of SQL Server CDC, triggers are placed in the source database that are set off instantly and automatically whenever a change occurs, significantly reducing data extraction costs. This form of CDC is easy to implement, with all details of the logs of transactions being present in the shadow tables.
In short, SQL Server CDC is a boon for businesses today.












