How to Migrate from SQLServer to Snowflake

Galaxy Glossary

How do I migrate a SQL Server database to Snowflake?

Move SQL Server schemas, data, and procedures into Snowflake using SnowSQL, external stages, and Snowpipe.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Description

Why migrate from SQL Server to Snowflake?

Snowflake separates storage and compute, auto-scales, and removes index management. This reduces ops work while boosting concurrency and pay-for-what-you-use costs.

Which high-level steps are required?

1) Extract data from SQL Server.
2) Land files in cloud storage.
3) Create Snowflake objects.
4) Load data with COPY or Snowpipe.
5) Validate row counts & types.
6) Cut over applications.

How do I extract data efficiently?

Use bcp or Azure Data Factory for TB-scale exports.Export each SQL Server table to compressed CSV or Parquet to minimize network I/O.

Example bcp command

bcp dbo.Customers out customers.csv -c -t"," -S sqlserver01 -d shop -U user -P pass

How do I stage files in cloud storage?

Choose the cloud Snowflake account runs on (S3, Azure Blob, GCS). Organize folders by schema/table for parallel loads.

Example AWS CLI upload

aws s3 cp customers.csv s3://shop-migration/customers/

What Snowflake objects must be created?

Create databases, schemas, tables, and stages.Match SQL Server data types to Snowflake equivalents (e.g., VARCHAR → STRING, DATETIME → TIMESTAMP_NTZ).

DDL sample

CREATE TABLE Customers (id INT, name STRING, email STRING, created_at TIMESTAMP_NTZ);

How do I load data with COPY?

Use COPY INTO from an external or internal stage.Define file format once and reuse.

COPY example

CREATE OR REPLACE FILE FORMAT csv_ff TYPE = 'CSV' FIELD_OPTIONALLY_ENCLOSED_BY='"';CREATE OR REPLACE STAGE s3_stage URL='s3://shop-migration/' CREDENTIALS=(AWS_KEY_ID='…' AWS_SECRET_KEY='…') FILE_FORMAT=csv_ff;COPY INTO Customers FROM @s3_stage/customers/ ON_ERROR='ABORT_STATEMENT';

How do I automate continuous loads?

Configure Snowpipe to watch the storage path and auto-ingest new files. Use an AWS SNS, Azure Event Grid, or GCP Pub/Sub notification channel.

How are stored procedures migrated?

Rewrite T-SQL procedures into Snowflake JavaScript or SQL UDFs.Focus on set-based logic; avoid cursors when possible.

What validation queries should I run?

Compare row counts and checksums between SQL Server and Snowflake. Sample query:
SELECT COUNT(*), SUM(total_amount) FROM Orders;

When do I cut over the application?

After validation, switch connection strings. Keep SQL Server in read-only mode until your Snowflake workload is stable.

Best practices for large migrations?

Parallelize loads, compress files, use Snowflake multi-table COPY, and enable clustering later to avoid extra cost during ingest.

.

Why How to Migrate from SQLServer to Snowflake is important

How to Migrate from SQLServer to Snowflake Example Usage


-- Load Products table after export
COPY INTO Products
FROM @s3_shop/products/
FILE_FORMAT = (TYPE=CSV FIELD_OPTIONALLY_ENCLOSED_BY='"')
ON_ERROR = 'CONTINUE';

How to Migrate from SQLServer to Snowflake Syntax


-- 1. Extract to CSV/Parquet from SQL Server
bcp dbo.Orders out orders.csv -c -t"," -S sql01 -d shop -U user -P pass

-- 2. Upload to cloud storage
aws s3 cp orders.csv s3://shop-migration/orders/

-- 3. Create Snowflake objects
CREATE OR REPLACE DATABASE shop;
USE DATABASE shop;
CREATE OR REPLACE SCHEMA ecommerce;
CREATE OR REPLACE TABLE Orders (
    id INT,
    customer_id INT,
    order_date TIMESTAMP_NTZ,
    total_amount NUMBER(10,2)
);

-- 4. Stage & load
CREATE OR REPLACE FILE FORMAT csv_ff TYPE=CSV FIELD_OPTIONALLY_ENCLOSED_BY='"';
CREATE OR REPLACE STAGE s3_shop URL='s3://shop-migration/' FILE_FORMAT=csv_ff;
COPY INTO Orders FROM @s3_shop/orders/;

-- 5. Validate
SELECT COUNT(*) AS rows_loaded, SUM(total_amount) AS total_sales FROM Orders;

Common Mistakes

Frequently Asked Questions (FAQs)

Is there a direct replication tool?

Snowflake partners like Fivetran and HVR provide near-real-time replication without manual extracts.

Can I keep SQL Server and Snowflake in sync?

Yes. Use Change Data Capture (CDC) to push deltas via Snowpipe or partner tools.

How do I handle identity columns?

Preserve values by defining the Snowflake column as NUMBER and loading the original IDs; use sequences only for new rows.

Want to learn about other SQL terms?