SQL Server › Change Data Capture (CDC)
How is Change Data Capture different from using triggers to track changes to a table?
IntermediateAnswer
CDC captures changes asynchronously by reading the transaction log in the background, adding minimal overhead to the original insert, update, or delete operation, while triggers run synchronously as part of the same transaction that made the change, which can add noticeable overhead and complexity directly to your application's write operations.
-- CDC reads the transaction log asynchronously
-- Triggers execute immediately within the same transaction
CREATE TRIGGER trg_AuditOrders ON Orders
AFTER INSERT, UPDATE, DELETE
AS BEGIN
-- custom logic runs synchronously here
END;Real-world example A team switches from a custom trigger based change tracking solution to CDC after noticing their triggers were slowing down every single order update, since CDC captures the same information with far less impact on write performance.