What you’ll need
- SQL Server 2012 and later, or Azure SQL Managed Instance, or Amazon RDS for SQL Server
- SQL Server Agent running, so the CDC capture and cleanup jobs run. On Amazon RDS, Agent is managed for you.
- A service account with
SELECTon the database - CDC enabled on the database and on each table you replicate
- The primary key columns included in each table’s capture instance
Setup
1
Create a service account
2
Enable CDC on the database
EXEC msdb.dbo.rds_cdc_enable_db 'ANALYTICS'; instead.If CDC isn’t enabled on the database, the pipeline stops with database "ANALYTICS" is not enabled for SQL Server CDC.3
Set the retention period
The CDC cleanup job deletes changes older than the retention period. The default is 3 days. Set it to cover the longest time your pipeline could be paused or down. We recommend 7 days.
4
Enable CDC on each table
@role_name and add the artie user to it.The capture instance must include the table’s primary key columns. If it doesn’t, the pipeline stops with CDC capture instance "dbo_orders" for table dbo.orders does not capture primary key column "id".5
Enter the connection in Artie
In Source, enter the Host, Port (default
1433), Username, Password and database. Under Replication method, select Capture instances.If you use an Always On availability group, enter the listener as the host. See High availability and failover.Advanced
How Artie reads changes
How Artie reads changes
- Every 2.5 seconds, Artie checks
sys.fn_cdc_get_max_lsn(). If it has moved, Artie reads each capture instance withcdc.fn_cdc_get_all_changes_<capture_instance>and theall update oldoption, 10,000 rows at a time, until it catches up. It reads up to 10 capture instances at once. - Each update arrives as one message with the row’s values before and after the change. Each change carries its commit time from
sys.fn_cdc_map_lsn_to_time. - Artie saves its position (LSN, sequence value and operation per capture instance) only after every change it read has been written to its Kafka buffer. If the pipeline restarts, it replays from the saved position, so some changes can arrive twice. The destination merges on the primary key, so the result is the same.
Schema changes
Schema changes
A capture instance keeps the columns the table had when it was created. To capture a new column, create a second capture instance, then drop the old one.Artie looks up capture instances when the pipeline starts. Redeploy the pipeline after you create the new capture instance. Artie then reads the old capture instance up to the point where the new one starts, and continues from the new one.Keep the old capture instance until the pipeline has switched over. Then drop it:Until you redeploy, a new column isn’t replicated.
Unique index override
Unique index override
By default,
sys.sp_cdc_enable_table identifies rows by the table’s primary key. To use a different unique index, set @index_name.Capture job not running
Capture job not running
SQL Server Agent’s capture job copies changes from the transaction log into the change tables. If the job stops, Start the job with
sys.fn_cdc_get_max_lsn() stops moving and Artie has no new changes to read. The pipeline stays running and reports no errors.No changes are lost while the job is stopped: SQL Server keeps them in the log. To check the job:EXEC sys.sp_cdc_start_job @job_type = N'capture';.Limitations
TRUNCATE TABLEisn’t allowed on CDC-tracked tables. UseDELETE.- Columns added after a capture instance was created aren’t replicated until you rotate the capture instance and redeploy. See Schema changes.
- If the pipeline is down longer than the CDC retention period, the changes SQL Server cleaned up are lost. Backfill the affected tables.

