Extracting changes reliably is half the job. The other half is applying them in the warehouse so that every record ends up in its latest state, with no duplicates and no older values overwriting newer ones.
Snowflake makes this straightforward once a few decisions are made correctly: how to store SQL Server’s rowversion, how files get from the source into Snowflake, and how the final MERGE decides which version of a row wins.
Step 1: Store rowversion as a number
Snowflake has no equivalent of SQL Server’s rowversion. You only need it as a sortable value, so convert it during extraction:
-- In SQL Server, during extraction
SELECT
ItemID,
ItemName,
Quantity,
CAST(RowVer AS BIGINT) AS RowVerNumeric
FROM dbo.LargeInventoryTable
WHERE RowVer > @LastProcessedVer
AND RowVer <= @ChunkMaxVer;
In Snowflake, store it in a NUMBER column. That makes comparisons and ORDER BY simple and fast. (rowversion is 8 bytes; values large enough to overflow a signed BIGINT are not reached in practice, but if you prefer, you can store the hex string or BINARY and compare that instead.)
Step 2: Land files in a data lake, then bulk load
Row-by-row INSERT statements into Snowflake are slow and expensive. The efficient pattern goes through object storage:
SQL Server → compressed Parquet → S3 / Azure Blob / GCS → Snowflake raw table → final table
This landing zone is more than a staging area. It is a durable, low-cost record of every change you have extracted, in an open format. You can replay loads from it after a mistake, feed other consumers such as data science workloads, and keep history cheaply outside the warehouse. For many organisations, this is the first useful layer of their data lake.
Connect Snowflake to storage securely
Use a storage integration so that no cloud keys appear in SQL or in your repository:
CREATE STORAGE INTEGRATION s3_landing_int
TYPE = EXTERNAL_STAGE
STORAGE_PROVIDER = 'S3'
ENABLED = TRUE
STORAGE_AWS_ROLE_ARN = 'arn:aws:iam::<account-id>:role/<snowflake-landing-role>'
STORAGE_ALLOWED_LOCATIONS = ('s3://my-landing-bucket/landing/');
CREATE STAGE landing.inventory_stage
URL = 's3://my-landing-bucket/landing/LargeInventoryTable/'
STORAGE_INTEGRATION = s3_landing_int
FILE_FORMAT = (TYPE = PARQUET);
Bulk load into a transient raw table
CREATE TRANSIENT TABLE IF NOT EXISTS raw.inventory_raw (
item_id INT,
item_name STRING,
quantity INT,
row_version NUMBER,
loaded_at TIMESTAMP_LTZ DEFAULT CURRENT_TIMESTAMP()
);
COPY INTO raw.inventory_raw (item_id, item_name, quantity, row_version)
FROM (
SELECT $1:ItemID::INT,
$1:ItemName::STRING,
$1:Quantity::INT,
$1:RowVerNumeric::NUMBER
FROM @landing.inventory_stage
);
COPY INTO keeps load history for each file, so it won’t load the same file twice if a run is repeated. Transient tables skip Snowflake’s fail-safe storage, which lowers cost for data you can always reload from the landing zone.
Step 3: Apply changes with a guarded MERGE
A single row may change several times between runs, and files can occasionally be processed out of order. The MERGE below handles both:
CREATE TABLE IF NOT EXISTS analytics.inventory (
item_id INT,
item_name STRING,
quantity INT,
row_version NUMBER
);
MERGE INTO analytics.inventory AS target
USING (
-- Keep only the latest version of each key in this batch
SELECT item_id, item_name, quantity, row_version
FROM raw.inventory_raw
QUALIFY ROW_NUMBER() OVER (PARTITION BY item_id ORDER BY row_version DESC) = 1
) AS source
ON target.item_id = source.item_id
WHEN MATCHED AND source.row_version > target.row_version THEN
UPDATE SET
target.item_name = source.item_name,
target.quantity = source.quantity,
target.row_version = source.row_version
WHEN NOT MATCHED THEN
INSERT (item_id, item_name, quantity, row_version)
VALUES (source.item_id, source.item_name, source.quantity, source.row_version);
Two parts do the important work:
QUALIFY ROW_NUMBER() ... = 1reduces the batch to one row per key, keeping the most recent version. Without it, theMERGEwould fail or behave unpredictably when a key appears more than once.source.row_version > target.row_versionmeans an update is only applied if it is newer than what the warehouse already holds. If an older file is replayed or processed late, it cannot overwrite newer data.
After a successful merge, clear or archive the raw table so the next run only processes new data.
Things that catch teams out
- Snowflake does not enforce primary keys. You can declare one for documentation and tooling, but Snowflake will not reject duplicates. De-duplication has to happen in your load logic, as above.
- Deletes need their own path. As covered in The Silent Data Loss Bug in Incremental ETL,
rowversiondoesn’t capture deleted rows. If you use soft deletes, add the flag to theMERGE. If you use Change Tracking, add aWHEN MATCHED AND source.is_deleted THEN DELETEbranch fed from the deleted keys. - Clustering is for very large tables only. If the target grows to multiple terabytes and merges slow down, a clustering key on the join column can help Snowflake prune data. On smaller tables it just adds maintenance cost.
Summary
| Decision | Recommendation |
|---|---|
rowversion in Snowflake | NUMBER |
| Transport | Compressed Parquet in object storage |
| Credentials | Storage integration, no keys in code |
| Raw layer | Transient table loaded with COPY INTO |
| Final layer | MERGE with in-batch de-duplication and a newer-version guard |
| Deletes | Explicit strategy: soft delete, Change Tracking, or reconciliation |
Next steps
Whether you are moving an existing warehouse to Snowflake or building your first data lake, getting the load pattern right early prevents expensive rework later. YenDigital can design the landing zone, the Snowflake layers and the load logic with your team.
