Most database tables only ever show you their present. Ask an orders table what it holds and it tells you today’s values, not the price a row carried yesterday or the customer it belonged to before someone deleted it.
CDC in SQL Server exists to close that gap. Change data capture records every insert, update and delete on the tables you choose, and stores those changes in ordinary tables that any application can query.
The easiest way to understand it is to follow one changed row on its journey. An UPDATE commits somewhere in your database; this article walks beside that row through the five stops it makes before a reporting tool ever sees it.
Stop One: The Change Commits, and the Log Remembers
SQL Server writes every change to a table to the transaction log before it treats the change as durable. Inserts, updates and deletes all leave entries there, in commit order, whether or not anyone ever reads them.
That log is the source CDC feeds on. Change data capture does not attach triggers to your tables, and it does not poll them with queries. It reads the record SQL Server already keeps.
This also means CDC is asynchronous. Your transaction commits immediately; the change becomes visible to consumers only after a separate process has read the log entry. The delay is usually small, but it is real.
Stop Two: The Capture Job Reads the Log
On SQL Server and Azure SQL Managed Instance, a SQL Server Agent job called the capture job does the reading. It scans the transaction log, picks out the entries that belong to CDC-enabled tables, and processes them in batches.
The capture logic is the same internal machinery, sp_replcmds, that transactional replication uses to harvest the log. If replication and CDC run on the same database, one log reader serves both, so the log is only scanned once.
A second Agent job, the cleanup job, handles deletion later in the journey. Both jobs need SQL Server Agent running. In Azure SQL Database there is no Agent, so a built-in scheduler runs capture every 20 seconds and cleanup every hour instead.
The Log Cannot Be Truncated Yet
One consequence surprises many teams. While a database is enabled for CDC, the transaction log cannot be truncated past changes the capture process has not yet read, even if the database uses the simple recovery model.
If the capture job stops or falls behind, the log keeps growing. Many CDC incidents announce themselves as a disk filling with log file, not as an error in the change tables.
Stop Three: The Row Lands in a Change Table
The capture process writes our updated row into a change table. Enabling a table creates a capture instance: a change table named like cdc.dbo_Orders_CT, plus query functions, all living in a dedicated cdc schema.
The change table mirrors the captured columns of the source table, with five metadata columns in front of them. Those five columns are what turn a copied row into a usable change record.
Reading the Metadata Columns
The column __$start_lsn holds the commit log sequence number, which orders transactions against each other. A second column, __$seqval, orders several changes made inside the same transaction.
The column __$operation says what happened: 1 is a delete, 2 is an insert, 3 is an update’s before image and 4 is an update’s after image. Our single UPDATE therefore arrives as two rows, showing the values before and after.
The last column, __$update_mask, is a bitmask with one bit per captured column. For updates it marks exactly which columns changed, so a consumer can ignore rows where only an irrelevant field moved.
| You may also like: |
|---|
| ERP cloud transformation |
| expense management tools |
Stop Four: Your Application Reads the Changes
Consumers rarely query the change table directly. Each capture instance provides a function, cdc.fn_cdc_get_all_changes_<instance>, that returns every change inside a log sequence number window you supply.
If the table was enabled with net changes support, a second function returns one row per changed record, holding its final state in the window. That is the version most incremental ETL jobs actually want.
Helper functions translate between the two worlds consumers think in. sys.fn_cdc_get_min_lsn and sys.fn_cdc_get_max_lsn give the available window. And sys.fn_cdc_map_time_to_lsn converts a clock time into the LSN you need.
DECLARE @from_lsn binary(10) = sys.fn_cdc_get_min_lsn('dbo_Orders');
DECLARE @to_lsn binary(10) = sys.fn_cdc_get_max_lsn();
SELECT *
FROM cdc.fn_cdc_get_net_changes_dbo_Orders(@from_lsn, @to_lsn, 'all');
Access can be fenced off. When you enable a table you may name a gating role, and only members of that role can read its change data. Setting the role to NULL leaves the data readable by anyone with ordinary permissions.
Stop Five: The Cleanup Job Deletes the Evidence
Our row’s journey ends with deletion. The cleanup job continuously removes change rows that fall outside the retention window, and by default that window is three days.
Three days is a processing deadline, not an archive. A consumer that falls further behind than the retention window loses the changes in between permanently, because the query functions refuse LSN ranges that are no longer available.
This is also why CDC is not a backup tool, despite what some explainers claim. A backup you can restore from next month is a different thing from a change feed that prunes itself every few days.
Switching CDC On: The Short Version
Enabling CDC happens in two steps, at two permission levels. A member of the sysadmin role enables the database; after that, members of db_owner can enable individual tables.
EXEC sys.sp_cdc_enable_db;
GO
EXEC sys.sp_cdc_enable_table
@source_schema = N'dbo',
@source_name = N'Orders',
@role_name = NULL,
@supports_net_changes = 1;
GO
Two requirements catch people out. Net changes only works if the table has a primary key, or a unique index you name with @index_name. And a primary key added after enabling is ignored by CDC, so create keys before you switch a table on.
Check Your Edition First
CDC arrived in SQL Server 2008, but only in the Enterprise, Developer and Datacenter editions. SQL Server 2016 SP1 widened it to Standard and Web editions, which is where most production use sits today.
Express and LocalDB still cannot run it, because those editions have no SQL Server Agent to run the capture and cleanup jobs. Azure SQL Managed Instance supports CDC fully; Azure SQL Database supports it on any vCore tier, or at S3 and above on the DTU model.
Where CDC in SQL Server Earns Its Keep
Incremental ETL and Warehouse Loads
The consumer Microsoft designed CDC for is the ETL process. Instead of copying whole tables every night, a load reads only the rows that changed since the last run and applies those to the warehouse.
The pattern needs one companion step: an initial snapshot. CDC captures changes from the moment you enable it, not the table’s existing contents, so the first load still copies the data as it stands.
Teams deciding whether their warehouse programme needs outside help often pair this design work with data analytics consulting. The tooling is built in; the modelling of what to load is the harder part.
Sync, Caches and Audit Trails
The same change stream can keep a search index, a cache or a second application database current. Operational systems behave the same way: an order change captured once can update stock, billing and the records inside expense management software without each system polling the others.
CDC change tables also serve as a short-term audit trail of who changed what values, within the retention window. They record the change, though, not who merely viewed the data, and compliance-grade auditing usually needs more than CDC alone.
For anything longer-lived, treat change data like any other sensitive record. Reviewing your digital footprint should include the copies of production data your pipelines scatter across systems.
| You may also like: |
|---|
| data analytics consulting |
| digital footprint checker |
The Limits Nobody Mentions in the Sales Pitch
Schema Changes Need a Plan
A capture instance keeps the column shape it was created with. Add a column to a tracked table and the existing instance simply ignores it; drop a captured column and later change rows carry NULL for it.
Data type changes on captured columns do propagate to the change table. CDC logs all structural changes in cdc.ddl_history, which you can inspect with sys.sp_cdc_get_ddl_history before they surprise a consumer.
The documented migration path is a second capture instance built on the new shape. A table can have two instances at once, so old and new consumers run in parallel until you retire the first.
Storage and Throughput Costs
Change tables live in the same database as your source tables, and they store every change as full row images. On a busy table, an update writes two extra rows. High-churn tables can grow change data faster than the source grows.
Watch the machinery, not just the tables. The DMVs sys.dm_cdc_log_scan_sessions and sys.dm_cdc_errors show capture sessions, latency and errors, and they are the first place to look when a consumer reports stale data.
Microsoft has also added a newer streaming option. Change event streaming, in preview in SQL Server 2025 and Azure SQL, publishes changes as events to Azure Event Hubs or Fabric Eventstream. It targets event-driven consumers; CDC remains the built-in, queryable option.
CDC vs Change Tracking vs Temporal Tables
SQL Server ships three features with overlapping reputations, and Microsoft positions them for different jobs. Choosing the wrong one usually means either missing data or needless weight.
Change Tracking: The Lightweight Option
Change tracking records only the primary key of each changed row, plus the fact and type of the change. It stores no column values and no intermediate versions; consumers join back to the source table to fetch the current row.
That is enough for synchronisation and caching, which is the role Microsoft documents for it. Microsoft’s own guidance is direct: if you need every change and its intermediate values, use change data capture instead.
Temporal Tables: History That Stays Home
System-versioned temporal tables, available since SQL Server 2016, keep a full history automatically in a history table beside the current one. You query past states with FOR SYSTEM_TIME, which is excellent for auditing and reconstructing what a table looked like last March.
The difference is direction. Temporal history stays inside the same database for you to query; it is not a feed designed to move changes into other systems. CDC exists precisely to carry changes out.
The rule of thumb is simple. Need to move changes elsewhere: CDC. If you only need to know which rows changed, cheaply, choose change tracking. Need to ask the database itself what it used to say: temporal tables.
Conclusion
CDC in SQL Server is a log reader with a filing system. It takes changes SQL Server already records, files them into change tables with enough metadata to replay them in order, and keeps them for a few days while your consumers collect them.
Used that way — incremental ETL, synchronisation, short-window audit — it is one of the most dependable features in the product, and it has been built in since 2008. Used as a backup, a permanent archive or an instant stream, it will disappoint you.
Start with one table, a named consumer and a retention window you have actually thought about. CDC rewards teams that know exactly who is reading the change tables, and it punishes, quietly and by deletion, the teams that never check.
FAQs
Is CDC in SQL Server the same as change tracking?
No. Change tracking records only which rows changed, identified by primary key, and consumers fetch current values from the source table. CDC stores the changed values themselves, including before and after images of updates, in change tables.
How long does CDC keep change data?
By default, three days. The cleanup job deletes change rows older than the retention setting, which you can raise or lower. Anything a consumer has not read before cleanup runs is gone for good.
Does CDC slow down the source database?
CDC adds no triggers and does not query your tables, so the write path stays light. The costs appear elsewhere: SQL Server holds the transaction log until capture reads it, and change tables consume storage inside the same database.
Which editions of SQL Server support CDC?
Enterprise and Standard editions of current versions, and Developer edition for development work. CDC reached Standard edition with SQL Server 2016 SP1; Express and LocalDB do not support it because they lack SQL Server Agent.
Can CDC replace backups or a full audit solution?
No. The cleanup job prunes change data after a few days by default, and CDC records changes rather than data access. Keep proper backups for recovery, and use dedicated auditing where regulations require a complete, long-term record.
