MS SQL replication
This feature requires installed dlthub package and an active license. You can self-issue a trial or join the waiting list for official access.
Copyright © 2025 dltHub Inc. All rights reserved.
dltHub provides a comprehensive solution for syncing an MS SQL Server table using Change Tracking, a solution similar to CDC. By leveraging SQL Server's native Change Tracking feature, you can efficiently load incremental data changes — including inserts, updates, and deletes — into your destination.
Prerequisites
Before you begin, ensure that Change Tracking is enabled on both your database and the tables you wish to track, as it is a feature that must be explicitly activated.
Enable Change Tracking on the database
Run the following SQL command to enable Change Tracking on your database:
ALTER DATABASE [YourDatabaseName]
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 7 DAYS, AUTO_CLEANUP = ON);
[YourDatabaseName]: Replace with the name of your database.CHANGE_RETENTION: Specifies how long Change Tracking information is retained. In this example, it’s set to 7 days.AUTO_CLEANUP: When set to ON, Change Tracking information older than the retention period is automatically removed.
Enable Change Tracking on the table
For each table you want to track, execute:
ALTER TABLE [YourSchemaName].[YourTableName]
ENABLE CHANGE_TRACKING
WITH (TRACK_COLUMNS_UPDATED = ON);
[YourSchemaName].[YourTableName]: Replace with your schema and table names.TRACK_COLUMNS_UPDATED: When set to ON, allows you to see which columns were updated in a row. Set to OFF if you don’t need this level of detail.
Set up dlthub and drivers
-
Make sure dltHub is installed according to the installation guide.
-
Install the Microsoft ODBC Driver for SQL Server according to the official instructions. If you prefer, there is also a Python library alternative.
-
Specify the credentials for your SQL Server connection according to the sql_database source instructions
Setting up the pipeline
The process involves two main steps:
- Initial full load: Use the
sql_tablefunction to perform a full backfill of your table data. - Incremental loading: Use the
create_change_tracking_tablefunction to load incremental changes using SQL Server's Change Tracking.
This approach ensures that you have a complete dataset from the initial load and efficiently keep it updated with subsequent changes.