πŸ”’ Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901
Guided DP-800 Domain 2
Domain 2 β€” Module 10 of 11 91%
20 of 28 overall

DP-800 Study Guide

Domain 1: Design and Develop Database Solutions

  • Table Design: Columns, Types, and Indexes Free
  • Constraints: Protecting Your Data Free
  • Specialised Tables and Graph Queries Free
  • JSON in SQL: Store, Query, and Index
  • Programmability: Views, Functions, Procedures, and Triggers
  • Advanced T-SQL: CTEs, Windows, and Correlated Queries
  • Pattern Power: Regular Expressions in T-SQL
  • Fuzzy String Matching: Finding Similar Text
  • AI-Assisted SQL with GitHub Copilot Free
  • MCP: Connecting AI to Your Database

Domain 2: Secure, Optimize, and Deploy Database Solutions

  • Encryption: Always Encrypted and Column-Level
  • Dynamic Data Masking and Row-Level Security
  • Permissions, Auditing, and Passwordless Access
  • Transaction Isolation and Concurrency
  • Query Performance: Plans, DMVs, and Query Store
  • SQL Database Projects: Build and Validate
  • CI/CD Pipelines for SQL Databases
  • Data API Builder: REST and GraphQL from SQL
  • Securing AI and API Endpoints
  • Change Detection: CES, CDC, and Change Tracking
  • Azure Integration and Monitoring

Domain 3: Implement AI Capabilities in Database Solutions

  • External AI Models: Choose, Create, Manage
  • Embeddings: Design, Chunk, and Generate
  • Choose Your Search Strategy
  • Vector Data: Types, Indexes, and Storage
  • Vector Search: Distance, ANN, and ENN
  • Hybrid Search and Reciprocal Rank Fusion
  • RAG with SQL: Prompt, Process, Respond

DP-800 Study Guide

Domain 1: Design and Develop Database Solutions

  • Table Design: Columns, Types, and Indexes Free
  • Constraints: Protecting Your Data Free
  • Specialised Tables and Graph Queries Free
  • JSON in SQL: Store, Query, and Index
  • Programmability: Views, Functions, Procedures, and Triggers
  • Advanced T-SQL: CTEs, Windows, and Correlated Queries
  • Pattern Power: Regular Expressions in T-SQL
  • Fuzzy String Matching: Finding Similar Text
  • AI-Assisted SQL with GitHub Copilot Free
  • MCP: Connecting AI to Your Database

Domain 2: Secure, Optimize, and Deploy Database Solutions

  • Encryption: Always Encrypted and Column-Level
  • Dynamic Data Masking and Row-Level Security
  • Permissions, Auditing, and Passwordless Access
  • Transaction Isolation and Concurrency
  • Query Performance: Plans, DMVs, and Query Store
  • SQL Database Projects: Build and Validate
  • CI/CD Pipelines for SQL Databases
  • Data API Builder: REST and GraphQL from SQL
  • Securing AI and API Endpoints
  • Change Detection: CES, CDC, and Change Tracking
  • Azure Integration and Monitoring

Domain 3: Implement AI Capabilities in Database Solutions

  • External AI Models: Choose, Create, Manage
  • Embeddings: Design, Chunk, and Generate
  • Choose Your Search Strategy
  • Vector Data: Types, Indexes, and Storage
  • Vector Search: Distance, ANN, and ENN
  • Hybrid Search and Reciprocal Rank Fusion
  • RAG with SQL: Prompt, Process, Respond
Domain 2: Secure, Optimize, and Deploy Database Solutions Premium ⏱ ~14 min read

Change Detection: CES, CDC, and Change Tracking

React to data changes with Change Event Streaming, Change Data Capture, Change Tracking, Azure Functions SQL triggers, and Logic Apps β€” know when to use each mechanism.

Knowing when your data changes

β˜• Simple explanation

Think of three ways to know when mail arrives at your house.

Change Tracking is like a flag on your mailbox β€” it flips up when new mail arrives. You know SOMETHING changed, but you have to open the box to see what it is. Lightweight and cheap.

Change Data Capture (CDC) is like a security camera pointed at your mailbox β€” it records every delivery. You can rewind and see exactly what was delivered, when, and by whom. More detailed but uses more storage.

Change Event Streaming (CES) is like a delivery notification pushed to your phone the instant the mail arrives. You do not have to check β€” the system tells YOU. Real-time, event-driven.

SQL Server and Azure SQL provide multiple mechanisms for detecting and reacting to data changes. Change Tracking records which rows changed (lightweight sync metadata). Change Data Capture (CDC) captures the full before/after values of changed rows in change tables. Change Event Streaming (CES) (new in SQL Server 2025) pushes change events to Azure Event Hubs in near real-time. Additionally, Azure Functions SQL trigger binding and Azure Logic Apps provide serverless and workflow-based reactions to changes. The exam tests your ability to choose the right mechanism for each scenario.

The big comparison

Change Tracking vs Change Data Capture vs Change Event Streaming
FeatureChange TrackingCDCCES
What it recordsWhich rows changed (row version)Full before/after column valuesChange events streamed externally
Storage impactMinimal (version numbers only)Moderate (change tables mirror source)Minimal on SQL (events go to Event Hubs)
LatencyPoll-based (you query for changes)Poll-based (read change tables)Near real-time push
History depthConfigurable retention (default 2 days)Configurable retentionDepends on Event Hubs retention
Old/new valuesNo β€” only which rows changedYes β€” full before and after imagesYes β€” change events include values
DestinationQuery from same databaseQuery from change tables in same databaseAzure Event Hubs (external consumers)
Best forSync scenarios (mobile offline sync, ETL delta loads)Audit trails, data warehousing, regulatory complianceReal-time event-driven architectures, microservices

Change Tracking

Change Tracking is the lightest option. It marks rows as changed and assigns version numbers, but does not store what the old values were.

Enable and use

-- Enable at database level
ALTER DATABASE VaultBankDB SET CHANGE_TRACKING = ON
  (CHANGE_RETENTION = 3 DAYS, AUTO_CLEANUP = ON);

-- Enable on a specific table
ALTER TABLE dbo.Customers ENABLE CHANGE_TRACKING
  WITH (TRACK_COLUMNS_UPDATED = ON);

Querying changes

-- Get the current version (your sync bookmark)
DECLARE @lastSync BIGINT = CHANGE_TRACKING_CURRENT_VERSION();

-- Later: get rows changed since last sync
SELECT
    ct.CustomerId,
    ct.SYS_CHANGE_OPERATION,   -- 'I' insert, 'U' update, 'D' delete
    ct.SYS_CHANGE_VERSION,
    c.FullName,
    c.Email
FROM CHANGETABLE(CHANGES dbo.Customers, @lastSync) AS ct
LEFT JOIN dbo.Customers c ON ct.CustomerId = c.CustomerId;

The pattern: save the version number after each sync. Next time, query for everything changed since that version. This is exactly how offline-capable mobile apps synchronise data β€” download only what changed since the last sync.

Change Data Capture (CDC)

CDC captures the complete before and after images of every changed row. It reads from the transaction log and writes to system-generated change tables.

Enable and use

-- Enable CDC at database level
EXEC sys.sp_cdc_enable_db;

-- Enable on a specific table
EXEC sys.sp_cdc_enable_table
    @source_schema = 'dbo',
    @source_name = 'Transactions',
    @role_name = 'cdc_reader',
    @supports_net_changes = 1;

Reading changes

-- Get the LSN range for the last hour
DECLARE @from_lsn BINARY(10) = sys.fn_cdc_get_min_lsn('dbo_Transactions');
DECLARE @to_lsn BINARY(10) = sys.fn_cdc_get_max_lsn();

-- All individual changes (every insert, update, delete)
SELECT *
FROM cdc.fn_cdc_get_all_changes_dbo_Transactions(
    @from_lsn, @to_lsn, 'all update old');

-- Net changes (final state of each row, collapses multiple changes)
SELECT *
FROM cdc.fn_cdc_get_net_changes_dbo_Transactions(
    @from_lsn, @to_lsn, 'all');

Key difference: all_changes returns every individual change (a row updated three times shows three rows). net_changes returns only the final state (same row shows once with the last values).

πŸ’‘ Exam tip: All changes vs Net changes

This distinction appears frequently on the exam:

  • fn_cdc_get_all_changes β€” returns every change operation. Use for audit trails where you need the complete history of modifications.
  • fn_cdc_get_net_changes β€” collapses multiple changes to the same row into the final result. Use for ETL/data warehouse loads where you only need the current state.

If a question says β€œload the latest version of changed rows into a data warehouse,” the answer is net changes. If it says β€œrecord every modification for compliance,” the answer is all changes.

Change Event Streaming (CES)

CES is the newest option, introduced with SQL Server 2025. Instead of polling for changes, CES pushes change events to Azure Event Hubs in near real-time.

Why CES matters

With Change Tracking and CDC, your consuming application must poll β€” repeatedly asking β€œdid anything change?” CES flips this model. Changes are streamed out as events the moment they happen. Downstream systems (microservices, analytics pipelines, notification systems) subscribe to the event stream.

Setup

-- Create an event streaming group
EXEC sys.sp_change_event_streaming_create_group
    @group_name = 'TransactionEvents',
    @event_hub_namespace = 'vaultbank-events.servicebus.windows.net',
    @event_hub_name = 'transactions',
    @credential_name = 'EventHubCredential';

-- Add a table to the streaming group
EXEC sys.sp_change_event_streaming_add_table
    @group_name = 'TransactionEvents',
    @schema_name = 'dbo',
    @table_name = 'Transactions';

Events arrive at Event Hubs in near real-time. From there, Azure Stream Analytics, Azure Functions, or any Event Hubs consumer can process them.

CES vs CDC

AspectCDCCES
Consumer pulls or system pushes?Consumer polls change tablesSystem pushes to Event Hubs
Where is change data stored?In the SQL database (change tables)In Azure Event Hubs (external)
Database storage impactChange tables grow with volumeMinimal β€” events leave the database
Real-time capabilityNear real-time with frequent pollingTrue near real-time streaming
Best consumer typeSQL queries, ETL toolsEvent-driven services, stream processors
πŸ’‘ Scenario: Dev builds real-time fraud detection at PixelForge

PixelForge Studios processes in-game purchase transactions. Dev Kapoor needs to detect suspicious purchasing patterns in real-time β€” not minutes later.

CDC would work but requires polling the change tables every few seconds, adding load to the database. Instead, Dev enables CES on the Transactions table, streaming events to Azure Event Hubs. An Azure Stream Analytics job watches the stream for patterns (multiple high-value purchases from the same account within seconds). Suspicious patterns trigger an Azure Function that flags the account.

The key insight: CES removes the polling loop. The database pushes events outward instead of consumers pulling inward.

Azure Functions SQL trigger binding

Azure Functions can react to SQL changes without you writing polling logic. The SQL trigger binding uses Change Tracking under the hood.

// Azure Function triggered by changes to the Orders table
[FunctionName("OrderChanged")]
public static void Run(
    [SqlTrigger("[dbo].[Orders]",
        ConnectionStringSetting = "SqlConnectionString")]
    IReadOnlyList<SqlChange<Order>> changes,
    ILogger log)
{
    foreach (var change in changes)
    {
        log.LogInformation($"Order {change.Item.OrderId} was {change.Operation}");

        if (change.Operation == SqlChangeOperation.Insert)
        {
            // Send order confirmation email
            SendConfirmation(change.Item);
        }
    }
}

Key facts:

  • Requires Change Tracking enabled on the table (the binding manages this automatically)
  • Tracks changes using a leases table in the database
  • Supports Insert, Update, and Delete operations
  • Scales with Azure Functions consumption plan (pay per execution)

Azure Logic Apps

Logic Apps provide a no-code/low-code approach to reacting to data changes. They use the SQL connector with triggers like β€œWhen an item is modified”:

Trigger: When a row is modified in dbo.Orders
  β†’ Condition: Order.Status equals 'Shipped'
    β†’ Yes: Send email notification via Office 365
    β†’ Yes: Update tracking record in Cosmos DB
    β†’ No: Do nothing

Logic Apps are best when the reaction involves multiple services (email, Teams, external APIs) and the team prefers visual workflow design over code.

Choosing the right mechanism

Choosing the right change detection mechanism
ScenarioBest ChoiceWhy
Mobile app offline syncChange TrackingLightweight, only needs to know which rows changed since last sync
Data warehouse incremental loadCDC (net changes)Needs current state of changed rows, does not need real-time
Regulatory audit trailCDC (all changes)Must record every modification with before/after values
Real-time event-driven microservicesCESPush-based, near real-time, decouples consumers from database
Send email when order shipsAzure Functions SQL trigger or Logic AppsServerless reaction, no infrastructure to manage
Complex multi-service workflow on changeLogic AppsVisual designer, built-in connectors for hundreds of services
Question

What is the key difference between Change Tracking and CDC?

Click or press Enter to reveal answer

Answer

Change Tracking records WHICH rows changed (version numbers only β€” lightweight). CDC records the complete BEFORE and AFTER values of every changed column (detailed but heavier on storage). Use Change Tracking for sync scenarios; use CDC for audit trails and data warehousing.

Click to flip back

Question

What is Change Event Streaming (CES) and how is it different from CDC?

Click or press Enter to reveal answer

Answer

CES pushes change events to Azure Event Hubs in near real-time. Unlike CDC, which stores changes inside the database for consumers to poll, CES sends events externally the moment they happen. This reduces database load and enables true event-driven architectures without polling loops.

Click to flip back

Question

What does the Azure Functions SQL trigger binding use under the hood?

Click or press Enter to reveal answer

Answer

The SQL trigger binding uses Change Tracking internally. It enables Change Tracking on the target table (if not already enabled) and maintains a leases table to track which changes have been processed. You do not need to manage the polling or version tracking β€” the binding handles it.

Click to flip back

Question

When should you use fn_cdc_get_net_changes instead of fn_cdc_get_all_changes?

Click or press Enter to reveal answer

Answer

Use net_changes when you only need the FINAL state of each changed row β€” typical for ETL loads into a data warehouse. Use all_changes when you need the complete modification history β€” required for audit compliance where every individual change must be recorded.

Click to flip back

Knowledge Check

Priya at Vault Bank needs to load changed transaction data into a data warehouse every night. She only needs the latest version of each changed row, not every intermediate change. The data warehouse loads run as a scheduled batch job. Which mechanism should she use?

Knowledge Check

Dev at PixelForge needs to detect fraudulent in-game purchases within seconds of them occurring. The fraud detection service runs as a separate microservice outside the SQL database. Which approach is best?

🎬 Video coming soon

Next up: Azure Integration and Monitoring β€” monitor your SQL databases, DAB endpoints, and pipelines with Azure Monitor, Application Insights, and Log Analytics.

← Previous

Securing AI and API Endpoints

Next β†’

Azure Integration and Monitoring

Guided

I learn, I simplify, I share.

A Guide to Cloud YouTube Feedback

© 2026 Sutheesh. All rights reserved.

Guided is an independent study resource and is not affiliated with, endorsed by, or officially connected to Microsoft. Microsoft, Azure, and related trademarks are property of Microsoft Corporation. Always verify information against Microsoft Learn.