Most incremental loads I've seen are built on one line.
WHERE Id > @LastLoadedId
Enter fullscreen mode
Exit fullscreen mode
It's fast, it's easy to explain, and it passes every test you're likely to write. On a busy database it also drops rows now and then, with no error and no warning. The fact table just ends up slightly short, and nobody notices until finance asks why the warehouse and the ledger disagree by 500.00.
I wanted to see this happen rather than take it on faith, so I reproduced it on a double-entry ledger I've been building in SQL Server for a savings and credit co-op. This post walks through the reproduction, explains why it happens, and shows the fix I ended up using.
The setup
The source is an append-only ledger. Every money movement is a row in JournalEntry with two or more rows in JournalLine . Nothing is ever updated or deleted, so it looks like the easiest possible table to load incrementally.…