DEV Community

Cover image for SQL Server to Redshift: Replicate Change Tables Through AWS Glue, Step by Step
Shubham Baldava
Shubham Baldava

Posted on

SQL Server to Redshift: Replicate Change Tables Through AWS Glue, Step by Step

Moving SQL Server to Redshift is easy once and tedious after that. A bcp export, an upload to Amazon S3 and a COPY land one table, and a row updated at lunch keeps its old value in Redshift until the next full reload.

SQL Server already records what changed. With change data capture (CDC) on, the SQL Server Agent copies every insert, update and delete from the transaction log into change tables, so the open question is who reads them and where the rows go.

The usual ways to wire this up:

  • bcp export, then COPY. The bulk copy program writes files, a script stages them in S3, and Redshift's COPY loads them. Freshness is hours to daily, and changes only show up through full reloads.
  • AWS Database Migration Service (DMS). A replication instance and a task read SQL Server's log or its CDC tables and apply the changes to native Redshift tables, through an S3 staging bucket.
  • Debezium, Kafka and a Redshift sink. The Debezium SQL Server connector streams the change tables into Kafka within seconds, and a sink writes them to Redshift. You run Kafka, Kafka Connect and both connectors.

This tutorial takes a fourth route. OLake Go, an open source (Apache 2.0) replication tool, drains the change tables on a schedule and commits Apache Iceberg tables into the AWS Glue Data Catalog, with the files in your own bucket. Redshift queries them in place through an external schema, and Athena and DuckDB open the same files.

I ran every step on 2026-10-30 with SQL Server 2022 Developer in Docker, OLake Go v1.1.0 in OLake UI, and a Redshift Serverless workgroup at 8 Redshift Processing Units (RPU) in ap-southeast-1. Every timing and row count below comes from that run.

The SQL Server to Redshift setup at a glance

  • Source: database shop with dbo.customers and dbo.orders, CDC on for both.
  • Writer: OLake Go in Docker Compose. The first sync saves the current log sequence number (LSN) and copies each table in parallel chunks; later syncs read the change tables from that LSN.
  • Catalog and storage: a Glue database per job, with Parquet data and delete files in S3.
  • Readers: Redshift through an external schema, plus Athena and DuckDB.

Before you start: SQL Server 2016 SP1 or later (Developer, Standard or Enterprise) with the Agent running, an AWS account, Redshift Serverless or an RA3 cluster, Docker, and about 40 minutes.

Step 1: Turn on CDC in SQL Server

Point OLake Go at your own tables if you have them. To reproduce this run, create these two in a database named shop and insert some rows; I started with 8 customers and 40 orders.

CREATE TABLE dbo.customers (
  id INT IDENTITY(1,1) PRIMARY KEY,
  name NVARCHAR(100), email NVARCHAR(200), city NVARCHAR(100), tier NVARCHAR(20),
  created_at DATETIME2 DEFAULT SYSUTCDATETIME(),
  updated_at DATETIME2 DEFAULT SYSUTCDATETIME());

CREATE TABLE dbo.orders (
  id INT IDENTITY(1,1) PRIMARY KEY,
  customer_id INT REFERENCES dbo.customers(id),
  product NVARCHAR(100), amount DECIMAL(10,2), status NVARCHAR(20),
  created_at DATETIME2 DEFAULT SYSUTCDATETIME(),
  updated_at DATETIME2 DEFAULT SYSUTCDATETIME());
Enter fullscreen mode Exit fullscreen mode

Next, switch CDC on for the database and for each table, and give OLake Go a login of its own:

USE shop;
EXEC sys.sp_cdc_enable_db;

-- @role_name = NULL skips the gating role
EXEC sys.sp_cdc_enable_table @source_schema = N'dbo', @source_name = N'customers', @role_name = NULL;
EXEC sys.sp_cdc_enable_table @source_schema = N'dbo', @source_name = N'orders',    @role_name = NULL;

USE master;
CREATE LOGIN olake WITH PASSWORD = '<password>';
USE shop;
CREATE USER olake FOR LOGIN olake;
GRANT SELECT ON SCHEMA :: dbo TO olake;
GRANT SELECT ON SCHEMA :: cdc TO olake;
GRANT VIEW DATABASE STATE TO olake;

-- the source test reads the capture job definition from msdb
USE msdb;
CREATE USER olake FOR LOGIN olake;
GRANT SELECT ON dbo.cdc_jobs TO olake;
Enter fullscreen mode Exit fullscreen mode

Confirm all three pieces exist before going further:

SELECT name, is_cdc_enabled FROM sys.databases WHERE name = 'shop';   -- 1
SELECT capture_instance FROM cdc.change_tables;                        -- dbo_customers, dbo_orders
EXEC msdb.dbo.sp_help_job @job_name = N'cdc.shop_capture';             -- the Agent job exists
Enter fullscreen mode Exit fullscreen mode

On a production server, four details matter:

  • The Agent fills the change tables. When it is stopped, nothing new lands in cdc.* and SQL Server reports no error. Amazon RDS and Azure SQL Managed Instance run it by default.
  • Retention is three days by default. A job paused for longer needs a fresh snapshot; sys.sp_cdc_change_job @job_type = 'cleanup' raises it.
  • Amazon RDS for SQL Server enables the database with EXEC msdb.dbo.rds_cdc_enable_db 'shop'. The table step and the login stay the same.
  • Each table needs a primary key. Without one, inserts replicate but updates and deletes are not applied.

Step 2: Set up S3, an IAM user and the Redshift role

Create three things in AWS:

  1. An S3 bucket in the region your engines run in. Mine was in ap-southeast-1.
  2. An Identity and Access Management (IAM) user for OLake Go with an access key pair. I scoped it with this inline policy:
{
  "Version": "2012-10-17",
  "Statement": [
    { "Effect": "Allow", "Action": ["s3:ListBucket", "s3:GetBucketLocation"], "Resource": "arn:aws:s3:::<bucket>" },
    { "Effect": "Allow", "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:AbortMultipartUpload", "s3:ListMultipartUploadParts"], "Resource": "arn:aws:s3:::<bucket>/*" },
    { "Effect": "Allow",
      "Action": ["glue:GetDatabase", "glue:GetDatabases", "glue:CreateDatabase", "glue:GetTable", "glue:GetTables", "glue:CreateTable", "glue:UpdateTable", "glue:DeleteTable"],
      "Resource": ["arn:aws:glue:<region>:<account>:catalog", "arn:aws:glue:<region>:<account>:database/*", "arn:aws:glue:<region>:<account>:table/*/*"] }
  ]
}
Enter fullscreen mode Exit fullscreen mode
  1. An IAM role for Redshift, attached to the Serverless namespace or the RA3 cluster. Mine carried AmazonS3ReadOnlyAccess plus read access to Glue.

Leave Glue alone for now. OLake Go creates the database during the first sync and registers both tables in it.

Step 3: Run OLake UI and connect SQL Server

curl -sSL https://raw.githubusercontent.com/datazip-inc/olake-ui/master/docker-compose-v1.yml | docker compose -f - up -d
Enter fullscreen mode Exit fullscreen mode

Browse to http://localhost:8000 and sign in as admin with the password password. Open Sources, click Create Source, choose MSSQL, name it and keep the OLake Go version on the latest release.

Under Change data capture (CDC), keep Enable CDC on. Manage Capture Instance lets OLake Go create a new capture instance after a schema change, but it needs db_owner, so I left it off.

For the connection I used host host.docker.internal, because SQL Server ran in a separate container, with port 1433, database shop, user olake and SSL disabled.

OLake UI Edit source form for MSSQL on OLake Go v1.1.0 with Enable CDC on, host host.docker.internal, port 1433, database shop, user olake and SSL disabled

Set up source also checks CDC on the database, a capture instance per table and a readable capture job. When one fails, the dialog names the setting and what to run.

Step 4: Add the Glue destination

Open Destinations, click Create Destination, choose Apache Iceberg and set the catalog type to AWS Glue:

Field What I entered
S3 Path s3://<bucket>/lakehouse/
AWS Region ap-southeast-1, where both the bucket and the Glue catalog live
AWS Access Key, AWS Secret Key the key pair of the IAM user from step 2

OLake UI Edit destination form for Apache Iceberg with catalog type AWS Glue, an S3 path under the lab bucket, region ap-southeast-1 and an access key pair

Click Create. On an instance that has its own IAM role, leave both key fields empty and OLake Go uses the role.

Step 5: Create the job and run the first sync

Redshift is not in OLake Go's target engine picker yet, and that changes one setting on this job.

  1. Open Jobs, click Create Job, name it sql_server_to_redshift and pick a schedule.
  2. Select the source from step 3 and the destination from step 4.
  3. Under Advanced Settings, set Target Query Engines to AWS Athena and DuckDB.
  4. Click Next. On the Streams page, tick customers and orders and leave systranschemas unticked.
  5. For each table, set Full Refresh + CDC and Upsert, with Positional Deletes as the upsert type.
  6. Click Create Job, then choose Sync Now from the job's menu.

Positional deletes are what Redshift reads, and Athena and DuckDB read them as well. The systranschemas table appears because enabling CDC adds it to the database, and it has no capture instance.

OLake UI Streams Selection page with the dbo schema, customers and orders selected and systranschemas unticked, sync mode Full Refresh + CDC, ingestion mode Upsert and upsert type Positional Deletes on Iceberg format version V2

The first run copied 48 records (3.05 KB) in 18 seconds, container start included. The Glue database name joins the job, the source database and the schema, so mine is sql_server_to_redshift_shop_dbo; the Iceberg DB field at the top of the Streams page renames it before that first sync.

Step 6: Query the tables in Redshift

Open Redshift query editor v2 on the workgroup or cluster and map the Glue database once:

CREATE EXTERNAL SCHEMA lakehouse
FROM DATA CATALOG
DATABASE 'sql_server_to_redshift_shop_dbo'
IAM_ROLE default;

SELECT id, name, city, tier FROM lakehouse.customers ORDER BY id;
SELECT status, count(*) AS n, round(sum(amount), 2) AS total
FROM lakehouse.orders GROUP BY status ORDER BY status;
Enter fullscreen mode Exit fullscreen mode

IAM_ROLE default picks up the default role of the namespace or cluster; put a role ARN there if you keep several. Run this after the first sync and in the workgroup's region, since the Glue database does not exist before then.

The schema is read-only from Redshift's side. OLake Go writes the tables, so an INSERT or DELETE against them fails.

Step 7: Change rows in SQL Server and sync again

This is where an export script falls behind. Back in SQL Server, make 12 changes, 7 inserts and 5 updates:

INSERT INTO dbo.customers (name, email, city, tier) VALUES
  (N'Maya Patel', 'maya@example.com', N'Pune', 'silver'),
  (N'Lucas Silva', 'lucas@example.com', N'São Paulo', 'bronze');
INSERT INTO dbo.orders (customer_id, product, amount, status) VALUES
  (9, 'Laptop', 1299.00, 'placed'), (9, 'Mouse', 25.50, 'placed'),
  (10, 'Monitor', 349.99, 'placed'), (3, 'Keyboard', 89.00, 'placed'), (7, 'Webcam', 79.90, 'placed');
UPDATE dbo.customers SET tier = 'gold',       updated_at = SYSUTCDATETIME() WHERE name = N'Liam Carter';
UPDATE dbo.customers SET city = N'Abu Dhabi', updated_at = SYSUTCDATETIME() WHERE name = N'Zara Ali';
UPDATE dbo.orders    SET status = 'delivered', updated_at = SYSUTCDATETIME() WHERE id IN (1, 4, 7);
Enter fullscreen mode Exit fullscreen mode

Choose Sync Now again. OLake Go read 12 records (855 bytes) from the change tables in 13 seconds.

OLake UI Job Logs and History for sql_server_to_redshift showing two completed syncs, the first in 18 seconds and the second in 13 seconds

customers got one data file with 4 rows (2 inserts, plus new versions of the 2 updated customers) and one positional delete file retiring the 2 old versions. orders got 8 rows and 3 deletes in the same shape.

OLake UI sync log filtered to the Iceberg commit reports for customers and orders, showing addedDataFiles 1, addedPositionalDeleteFiles 1, addedRecords 4 and 8, and addedPositionalDeletes 2 and 3

Re-run the customers query with no refresh and no ALTER TABLE first. Liam Carter is gold, Zara Ali lives in Abu Dhabi, the two new customers are there, and Redshift returns one row per key.

Redshift query editor v2 in the AWS console running the customers query on the Serverless workgroup and returning 10 rows with id, name, city and tier

Add _op_type to the select to see how each row arrived: r on the 6 untouched snapshot rows, c on the 2 inserts and u on the 2 updates. A deleted row would carry d.

Read the same tables from Athena and DuckDB

No export runs here: both engines open the files OLake Go committed, through the same Glue database.

Athena lists the database with no registration. Pick a workgroup with a query result location in S3, then:

SELECT id, name, city, tier FROM sql_server_to_redshift_shop_dbo.customers ORDER BY id;
SELECT status, count(*) AS n, round(sum(amount), 2) AS total
FROM sql_server_to_redshift_shop_dbo.orders GROUP BY status ORDER BY status;
Enter fullscreen mode Exit fullscreen mode

Athena query editor in the AWS console showing the customers query on sql_server_to_redshift_shop_dbo.customers completed with 10 rows

DuckDB scans a table from its current metadata file, which Glue keeps as metadata_location:

aws glue get-table --database-name sql_server_to_redshift_shop_dbo --name customers \
  --query 'Table.Parameters.metadata_location' --output text
Enter fullscreen mode Exit fullscreen mode
INSTALL iceberg; LOAD iceberg;
INSTALL httpfs;  LOAD httpfs;
CREATE SECRET lake (TYPE s3, KEY_ID '<access key>', SECRET '<secret key>', REGION '<region>');

SELECT id, name, city, tier
FROM iceberg_scan('s3://<bucket>/lakehouse/sql_server_to_redshift_shop_dbo.db/customers/metadata/<latest>.metadata.json')
ORDER BY id;
Enter fullscreen mode Exit fullscreen mode

DuckDB 1.5.5 gave back the same 10 customers. The orders roll-up matched SQL Server to the cent in all three engines: 16 delivered for 8659.68, 18 placed for 10522.26 and 11 shipped for 6397.25.

Tips from the run

  • A fresh write can miss a sync. The capture job fills the change tables every few seconds, so a change made right before Sync Now may land in the next run.
  • Decimals become DOUBLE PRECISION. My sums still matched to the cent, but round at query time when exact decimal arithmetic matters.
  • Dates arrive as TIMESTAMP in UTC, and a uniqueidentifier arrives as its 36-character text form.
  • New columns need a new capture instance. Create one, or turn on Manage Capture Instance, and the column reaches Redshift after the next sync.
  • Plan compaction. Each sync adds a small data file and a delete file per table, and Glue does not compact tables written by external engines. Spark's rewrite_data_files on Amazon Elastic MapReduce (EMR) or OLake Fusion handles it.

SQL Server to Redshift methods side by side

Method How fresh Updates and deletes Where rows land What you operate
bcp to CSV, then COPY hours to daily full reloads only native Redshift tables a script, a scheduler, a staging bucket
AWS DMS CDC from the log or the CDC tables yes native Redshift tables a replication instance and task, plus S3 staging
Debezium, Kafka, Redshift sink seconds yes, with the sink's upsert settings Kafka topics, then Redshift tables Kafka, Kafka Connect, Debezium, a sink
OLake Go to Glue (this post) CDC on a schedule down to one minute yes, as Iceberg row-level deletes Iceberg tables Redshift, Athena, EMR, Spark and DuckDB read one Docker Compose stack, open source

When native Redshift tables are the only goal and you are already on AWS, DMS is simpler. Writing Iceberg once wins when Athena, EMR or a notebook needs the same rows, or when you want to own the files.

It is the wrong tool in three cases. Queries that must run at native Redshift speed suffer, because Redshift Spectrum scans the Parquet in S3 on every read; load the hot slice into a native table on a schedule. SQL Server Express and Web have no CDC at all, and tables with no primary key only ever get inserts.

FAQ

Do I have to refresh anything in Redshift after each sync?

No. Each sync ends with one commit that moves the table's metadata pointer in Glue, and Redshift reads that pointer on its next query. There is no ALTER TABLE and no refresh command.

What happens if the job is paused over a long weekend?

The cleanup job drops change rows older than three days by default. A longer pause loses the job's position and forces a new snapshot, so raise retention with sys.sp_cdc_change_job first.

Is a provisioned cluster fine, or only Serverless?

Both work. Redshift Serverless and RA3 clusters read the Glue Data Catalog through an external schema; attach the IAM role to the cluster instead of the namespace.

Where to go from here

  • Point the source at a real database.
  • Add a table with sys.sp_cdc_enable_table, then tick it on the job's Streams page.
  • The full guide, with the command line config, the data type table and every troubleshooting entry, is on olake.io.

If one of these steps answers you with a different message, paste it in the comments and I will dig into it.

Top comments (0)