Sync Snowflake batches to SQL Server every 5 minutes

Recipe ToolsMarketingDatabase

What it does

When the clock triggers every 5 minutes, this automation queries Snowflake and divides results into batches. Each batch then inserts into SQL Server so large tables move without overwhelming the destination.

Who it's for

Data and analytics teams who need to sync large Snowflake tables to SQL Server without overwhelming the destination database.

How teams use this

Move large tables without timeouts

Sync a Snowflake table with millions of rows to SQL Server by breaking it into batches. The batch size can be tuned so each insert completes before the next cycle starts.

Adjust batch size for performance

Set the batch_size variable to move more or fewer rows per cycle based on SQL Server capacity. Smaller batches reduce load; larger batches sync faster.

Sync a custom SQL query instead

Replace the table select with a custom SQL query in Snowflake to filter or transform rows before they land in SQL Server. The batch logic stays the same.

How it works

  1. Run every 5 minutes. The automation starts on a 5-minute schedule so batches move to SQL Server at regular intervals.
  2. Count total rows in Snowflake. Query Snowflake to get the total number of rows so the automation knows how many batches to create.
  3. Fetch each batch from Snowflake. Loop through each batch and retrieve rows from the Snowflake table using the batch size and offset variables to paginate results.
  4. Insert batch into SQL Server. Insert each batch of rows into the SQL Server table so the data arrives in manageable chunks without timeouts or connection issues.