Sync SQL Server daily to Snowflake via Amazon S3
Recipe ToolsDatabaseDocument/FileDeveloper Tool
What it does
When a scheduled time arrives each night, this automation exports data from SQL Server to a CSV file, uploads it to Amazon S3, and bulk loads it into Snowflake. If an error occurs, someone receives an email notification.
Who it's for
Data and analytics teams who need to synchronize SQL Server data to Snowflake on a daily schedule without manual intervention.
How teams use this
Automate nightly data warehouse refresh
Run the full SQL Server to Snowflake pipeline every night at 2 AM without manual steps. The team wakes up to fresh data in the warehouse ready for analysis.
Alert the team when sync fails
When the bulk load fails, someone gets an email so the data engineering team can investigate and fix the issue before business hours. Error visibility keeps the warehouse reliable.
Add data validation before load
Include a validation step after the CSV download to check row counts and data quality. Only proceed to Snowflake if the file meets expected thresholds, filtering out incomplete batches.
Sync multiple SQL Server tables
Extend the automation to export and load several tables instead of one. Set up a loop to process each table through the same S3 and Snowflake steps.
How it works
- Start the sync at 2 AM. The automation runs at 2 AM each day when network traffic is low, ensuring minimal impact on production systems.
- Execute the export stored procedure. Run the dbo.export_CSV stored procedure in SQL Server to transform and load data into a CSV file at a specified filepath.
- Download the CSV from on-premises. Retrieve the newly created CSV file from the on-premises file system so it can be transferred to the cloud.
- Upload the file to Amazon S3. Transfer the CSV file contents into the S3 bucket to stage the data for Snowflake ingestion.
- Bulk load data into Snowflake. Load data from the S3 staging table into the customer data table in Snowflake. If an error occurs, send an email notification.