Business Professionals
Power BI | Power Pivot | Power Query | DAX
Cloud Flows | RPA | AI Builder | Copilot
60+ Formulas | Data Stories | Advanced Reporting & Modeling
VB Programming | Report Automation |
MS-Office Automation
Techno-Business Professionals
Power BI | Power Query | Advanced DAX | SQL - Query &
Programming
Microsoft Fabric | Power BI | Power Query | Advanced DAX |
SQL - Query & Programming
Power BI | Power Apps | Power Automate | Copilot Studio | Power Pages | Dataverse
Microsoft Power Apps | Microsoft Power Automate
Power BI | Adv. DAX | SQL (Query & Programming) |
VBA | Python | Web Scrapping | API Integration
Power BI | Power Apps | Power Automate |
SQL (Query & Programming)
Power BI | Adv. DAX | Power Apps | Power Automate |
SQL (Query & Programming) | VBA | Python | Web Scrapping | API Integration
Power Apps | Power Automate | SQL | VBA | Python |
Web Scraping | RPA | API Integration
Technology Professionals
Power BI | DAX | SQL | ETL with SSIS | SSAS | VBA | Python
Power BI | SQL | Azure Data Lake | Synapse Analytics |
Data Factory | Databricks | Power Apps | Power Automate |
Azure Analysis Services
Microsoft Fabric | Power BI | SQL | Lakehouse |
Data Factory (Pipelines) | Dataflows Gen2 | KQL | Delta Tables | Power Apps | Power Automate
Power BI | Power Apps | Power Automate | SQL | VBA | Python | API Integration
Power BI | Advanced DAX | Databricks | SQL | Lakehouse Architecture
Business Professionals
Power BI | Power Pivot | Power Query | DAX
Cloud Flows | RPA | AI Builder | Copilot
60+ Formulas | Data Stories | Advanced Reporting & Modeling
VB Programming | Report Automation |
MS-Office Automation
Techno-Business Professionals
Power BI | Power Query | Advanced DAX | SQL - Query &
Programming
Microsoft Fabric | Power BI | Power Query | Advanced DAX |
SQL - Query & Programming
Power BI | Power Apps | Power Automate | Copilot Studio | Power Pages | Dataverse
Microsoft Power Apps | Microsoft Power Automate
Power BI | Adv. DAX | SQL (Query & Programming) |
VBA | Web Scrapping | API Integration
Power BI | Power Apps | Power Automate |
SQL (Query & Programming)
Power BI | Adv. DAX | Power Apps | Power Automate |
SQL (Query & Programming) | VBA | Web Scrapping | API Integration
Power Apps | Power Automate | SQL | VBA |
Web Scraping | RPA | API Integration
Technology Professionals
Power BI | DAX | SQL | ETL with SSIS | SSAS | VBA
Power BI | SQL | Azure Data Lake | Synapse Analytics |
Data Factory |
Azure Analysis Services
Microsoft Fabric | Power BI | SQL | Lakehouse |
Data Factory (Pipelines) | Dataflows Gen2 | KQL | Delta Tables
Power BI | Power Apps | Power Automate | SQL | VBA | API Integration
Power BI | Advanced DAX | Databricks | SQL | Lakehouse Architecture
Most data teams start with a daily full reload and quickly hit the wall: long runtimes, blown SLAs, and pressure from the business when the orders table isn't ready by 8am. You don't actually need all the data every time — you need only the new or updated orders. This walkthrough shows how to implement that pattern in Azure Data Factory (ADF) in a way that’s reliable, debuggable, and production‑ready.
We’ll use a simple but realistic scenario: an e‑commerce platform writing orders into an operational SQL database, and a data team loading those orders into an Azure SQL Database (or dedicated SQL pool) for reporting. The requirement is to load only new or changed orders, several times per day, using Azure Data Factory.
You have:
SalesDB, table dbo.Orders (OLTP), with columns:
OrderID (PK, INT)CustomerIDOrderDateStatusTotalAmountLastModifiedDate (datetime2, updated by the app on insert/update)AnalyticsDB, table dbo.FactOrders, used by Power BI.The anti‑pattern you’re replacing is a pipeline that truncates FactOrders and reloads everything from Orders on each run.
For this scenario, three patterns are common in ADF:
LastModifiedDate) + state stored in metadata.We’ll focus on pattern 1 with a watermark column, because:
You can layer CDC or Change Tracking on top later if needed; the ADF side looks very similar.
Assume your source table looks like this (simplified):
CREATE TABLE dbo.Orders
(
OrderID INT NOT NULL PRIMARY KEY,
CustomerID INT NOT NULL,
OrderDate DATETIME2(0) NOT NULL,
Status NVARCHAR(20) NOT NULL,
TotalAmount DECIMAL(18, 2) NOT NULL,
LastModifiedDate DATETIME2(3) NOT NULL
);
Key points:
LastModifiedDate must be monotonic per row (updated on insert and update).In AnalyticsDB, create a table that will be upserted:
CREATE TABLE dbo.FactOrders
(
OrderID INT NOT NULL PRIMARY KEY,
CustomerID INT NOT NULL,
OrderDate DATETIME2(0) NOT NULL,
Status NVARCHAR(20) NOT NULL,
TotalAmount DECIMAL(18, 2) NOT NULL,
LastModifiedDate DATETIME2(3) NOT NULL
);
You’ll load into a staging table and then MERGE into FactOrders.
CREATE TABLE dbo.StgFactOrders
(
OrderID INT NOT NULL,
CustomerID INT NOT NULL,
OrderDate DATETIME2(0) NOT NULL,
Status NVARCHAR(20) NOT NULL,
TotalAmount DECIMAL(18, 2) NOT NULL,
LastModifiedDate DATETIME2(3) NOT NULL
);
ADF needs to remember the last successful high watermark (max LastModifiedDate) between runs.
Common options:
We’ll use a control table in AnalyticsDB:
CREATE TABLE dbo.IncrementalState
(
PipelineName NVARCHAR(200) NOT NULL PRIMARY KEY,
LastWatermarkUtc DATETIME2(3) NOT NULL
);
INSERT INTO dbo.IncrementalState (PipelineName, LastWatermarkUtc)
VALUES ('OrdersIncrementalLoad', '2000-01-01T00:00:00.000');
Using a very old default date ensures the first run picks up all existing rows.
Create a pipeline called pl_Orders_Incremental with these activities:
StgFactOrders.StgFactOrders into FactOrders.IncrementalState.We’ll walk through each part.
Add a Lookup activity named GetWatermark:
AnalyticsDB.SELECT LastWatermarkUtc
FROM dbo.IncrementalState
WHERE PipelineName = 'OrdersIncrementalLoad';
Configure:
true.In downstream activities, you’ll reference it as:
@activity('GetWatermark').output.firstRow.LastWatermarkUtc
ADF will treat this as a string; SQL will cast it back to datetime2 automatically in the query below as long as the format is ISO‑like (which SQL Server accepts).
Add a Copy data activity named Copy_Orders_Incremental:
SalesDB.AnalyticsDB, table dbo.StgFactOrders.TRUNCATE TABLE dbo.StgFactOrders;
This ensures staging only contains the current batch.
In the Source -> Use query box, parameterise the watermark:
SELECT
OrderID,
CustomerID,
OrderDate,
Status,
TotalAmount,
LastModifiedDate
FROM dbo.Orders
WHERE LastModifiedDate > @{activity('GetWatermark').output.firstRow.LastWatermarkUtc};
ADF will inline the expression before sending the query to SQL. Because LastWatermarkUtc is stored as datetime2(3) in IncrementalState and the expression is injected without quotes, SQL Server will treat it as a datetime2 literal.
The simple > comparison can miss rows if:
LastModifiedDate as the watermark.To be safer, you can:
>= and track the max watermark from the source query itself.LastModifiedDate.We’ll implement that in the MERGE and watermark update steps.
Add a Stored procedure activity named Merge_Orders using AnalyticsDB.
Create the stored procedure:
CREATE OR ALTER PROCEDURE dbo.usp_MergeFactOrders
AS
BEGIN
SET NOCOUNT ON;
MERGE dbo.FactOrders AS tgt
USING dbo.StgFactOrders AS src
ON tgt.OrderID = src.OrderID
WHEN MATCHED AND tgt.LastModifiedDate < src.LastModifiedDate THEN
UPDATE SET
tgt.CustomerID = src.CustomerID,
tgt.OrderDate = src.OrderDate,
tgt.Status = src.Status,
tgt.TotalAmount = src.TotalAmount,
tgt.LastModifiedDate = src.LastModifiedDate
WHEN NOT MATCHED BY TARGET THEN
INSERT (
OrderID,
CustomerID,
OrderDate,
Status,
TotalAmount,
LastModifiedDate
)
VALUES (
src.OrderID,
src.CustomerID,
src.OrderDate,
src.Status,
src.TotalAmount,
src.LastModifiedDate
);
END;
Notes:
WHEN MATCHED predicate prevents older versions from overwriting newer ones if they reappear in staging.WHEN NOT MATCHED BY SOURCE THEN ... clause, but that requires a way to detect deletions (e.g. soft‑delete flag or Change Tracking/CDC).Configure the stored procedure activity to call dbo.usp_MergeFactOrders with no parameters.
You want to set the new watermark to the maximum LastModifiedDate actually processed from the source, not the current time.
Add another Stored procedure activity named Update_Watermark after Merge_Orders.
Create the procedure:
CREATE OR ALTER PROCEDURE dbo.usp_UpdateIncrementalState
@PipelineName NVARCHAR(200)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @NewWatermarkUtc DATETIME2(3);
SELECT @NewWatermarkUtc = MAX(LastModifiedDate)
FROM dbo.StgFactOrders;
IF @NewWatermarkUtc IS NULL
BEGIN
-- No new rows this run; keep existing watermark
RETURN;
END;
UPDATE dbo.IncrementalState
SET LastWatermarkUtc = @NewWatermarkUtc
WHERE PipelineName = @PipelineName;
END;
Configure the activity:
dbo.usp_UpdateIncrementalState.@PipelineName value:@pipeline().Pipeline
This ensures the watermark only moves forward when data actually arrived in staging.
Your pipeline flow should be:
GetWatermarkCopy_Orders_Incremental (on success of 1)Merge_Orders (on success of 2)Update_Watermark (on success of 3)Key behaviours:
StgFactOrders may be partially loaded, but Merge_Orders and Update_Watermark won’t run.src.LastModifiedDate is newer, reprocessing is idempotent.This pattern makes the pipeline at‑least‑once for each changed row but logically exactly‑once in the final fact table.
In a real project you’ll want to reuse the pattern for multiple tables.
Typical parameterisation:
p_SourceTableNamep_StagingTableNamep_FactTableNamep_PipelineKey (used in IncrementalState)QUOTENAME + dynamic SQL.For example, a more generic watermark update procedure:
CREATE OR ALTER PROCEDURE dbo.usp_UpdateIncrementalState_Generic
@PipelineName NVARCHAR(200),
@StagingTableName SYSNAME
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Sql NVARCHAR(MAX);
DECLARE @NewWatermarkUtc DATETIME2(3);
SET @Sql = N'SELECT @WM = MAX(LastModifiedDate) FROM ' + QUOTENAME(@StagingTableName) + N';';
EXEC sp_executesql
@Sql,
N'@WM DATETIME2(3) OUTPUT',
@WM = @NewWatermarkUtc OUTPUT;
IF @NewWatermarkUtc IS NULL
RETURN;
UPDATE dbo.IncrementalState
SET LastWatermarkUtc = @NewWatermarkUtc
WHERE PipelineName = @PipelineName;
END;
Call it from ADF with parameters based on pipeline parameters.
Watch these in ADF Studio:
In SQL, you can quickly check:
SELECT COUNT(*) AS FactRowCount FROM dbo.FactOrders;
SELECT LastWatermarkUtc FROM dbo.IncrementalState WHERE PipelineName = 'OrdersIncrementalLoad';
When you add a new table to the pattern:
IncrementalState.LastWatermarkUtc to a suitably old date.If you need to replay a time window (for example, after a source bug), you can temporarily set LastWatermarkUtc back to an earlier value and re‑run. Because of the LastModifiedDate comparison in the MERGE, you won’t corrupt existing data as long as the source’s LastModifiedDate values are consistent.
The watermark pattern works well when:
LastModifiedDate column.If you need to capture deletes or avoid relying on an application‑managed timestamp, consider:
The downstream MERGE pattern stays similar; only the source query and staging schema become more complex.
The core of an incremental orders pipeline in ADF is simple: a trusted watermark column, a persisted high watermark, and an idempotent MERGE that only applies newer changes. Once you have that pattern working for one table, you can standardise it across your project and stop paying the cost of full reloads every time the business wants fresher order data.
This article reflects a shift from full-table reloads to watermark-based incremental loading patterns in Azure Data Factory, particularly valuable for teams running frequent refreshes from OLTP systems into analytical SQL stores.
Professionals who want to apply these patterns to their own data can explore Excelgoodies' Azure Data Engineering Course programme - taught live by instructors, with certification awarded once a real project is running at work.
Insights compiled through ongoing industry research and discussions within the Excelgoodies Analytics Community.
Azure
New
Next Batches Now Live
Power BI
SQL
Power Apps
Power Automate
Microsoft Fabrics
Azure Data Engineering