Load only the rows that changed, with a watermark

An incremental load in Azure Data Factory asks the source only for rows changed since the last good run, merges them by key, and moves the watermark on only on success.

Short answer: store a watermark per table, the latest change you already loaded. Each run reads the highest change value in the source first, copies the rows between the old watermark and that value, merges them into the target by key, and only then moves the watermark on. A failed run leaves the watermark where it was, so the next run picks the same rows up again.

A full copy every night is simple, and it gets slower every month the data grows. Most tables have a column that says when a row last changed, usually a modified date. That column is enough to ask the source for the new rows only.

What is a watermark?

The highest value of the change column you have already loaded. Everything above it is new to you; everything at or below it you already have.

SalesOrderIDModifiedDateStatus
717742026-10-25 22:10Shipped
717762026-10-26 09:42Shipped
LastWatermark 2026-10-26 09:42
717802026-10-27 14:05Ordered
717762026-10-27 18:31Returned
NewWatermark 2026-10-27 18:31
One night's run on SalesOrderHeader: only the rows above the watermark are copied

Order 71776 shows up twice: the version the last run loaded, and the same order after it was returned. That second version is why the target needs a merge by key, not an insert: the changed row has to replace the old one.

How does one run work?

  1. 1
    Read the new watermarkMAX(ModifiedDate) in the source, before copying
  2. 2
    Copy the rows in betweenabove the old watermark, up to the new one
  3. 3
    Merge by keyupdate what changed, insert what is new
  4. 4
    Move the watermarkonly when the merge succeeded
An incremental run, in the order that keeps it safe

Reading the new watermark before the copy matters. A row that changes while the copy runs gets a later date than the value you read, so the next run copies it, instead of the watermark jumping past it.

The copy's source query in Data Factory, inside a ForEach over the control table:

SELECT * FROM @{item().SchemaName}.@{item().TableName}
WHERE @{item().WatermarkColumn} >  '@{item().LastWatermark}'
  AND @{item().WatermarkColumn} <= '@{activity('New watermark').output.firstRow.NewWatermark}'

The rows land in a staging table, and one stored procedure merges them into the target:

MERGE dbo.SalesOrderHeader AS t
USING stage.SalesOrderHeader AS s
    ON t.SalesOrderID = s.SalesOrderID
WHEN MATCHED THEN
    UPDATE SET t.Status = s.Status, t.ModifiedDate = s.ModifiedDate
WHEN NOT MATCHED BY TARGET THEN
    INSERT (SalesOrderID, Status, ModifiedDate)
    VALUES (s.SalesOrderID, s.Status, s.ModifiedDate);

The last step is a second stored procedure that writes the new watermark into the control table, on the Copy's and the merge's success path only.

Why not just copy the rows since yesterday?

Because "yesterday" is a guess about when the last run worked. If Tuesday's run fails and nobody notices until Thursday, a load of "the last 24 hours" has lost Tuesday's changes for good. The watermark is a fact about what you actually loaded, so a failed run, a paused trigger or a week's holiday all catch up on their own.

What does a watermark not catch?

  • Deleted rows. A deleted row has no modified date; it is simply gone. If deletes matter, use soft deletes in the source, or change tracking or change data capture, which record them.
  • Changes that do not touch the column. A bulk update that forgets to set ModifiedDate is invisible. Check with the source team how the column is maintained before you trust it.
  • Clock and time zone surprises. Compare like with like: if the source writes local time, keep the watermark in local time too, or convert both.

Where can you check this?

Where do you start?

The last lesson of Your first metadata-driven pipeline adds the watermark to a pipeline you build yourself, and Upserts into Azure SQL covers the staging table, the merge and a log of every run. The same idea in a Fabric lakehouse is Incremental loads in a lakehouse.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.