Skip to main content
Change tracking is a lightweight alternative to CDC. It records the primary key of the row that has changed and the operation and Artie will then query the source tables to retrieve the row data.This method is recommended if you cannot enable CDC for your database.

Required settings

  • Host name
  • Port (default is 1433)
  • Service account
  • Database name
  • Change tracking enabled for database and tables to replicate
USE [DATABASE_NAME];
CREATE LOGIN artie WITH PASSWORD = 'PASSWORD';
CREATE USER artie FOR LOGIN artie;
ALTER LOGIN artie ENABLE;
GRANT SELECT on DATABASE::DATABASE_NAME to artie;
GO;
To access the change tracking metadata, the service account must have the following permissions:
  • SELECT permission on at least the primary key columns on the change-tracked table to the table that is being queried.
  • VIEW CHANGE TRACKING permission on the table for which changes are being obtained.
Reference
In order to enable Change Tracking for SQL Server, you will enable it at the database and table level.
  1. Enable Change Tracking for your database
USE [DATABASE_NAME];
ALTER DATABASE [DATABASE_NAME]
SET CHANGE_TRACKING = ON
-- Specify the retention period of your Change Tracking tables.
-- We recommend you setting this between 24h to 7 days
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON);
  1. Enable CDC for your tables
ALTER TABLE [TABLE NAME] ENABLE CHANGE_TRACKING;

Troubleshooting

Microsoft Troubleshooting DocumentationCheck Change Tracking space usage
DECLARE @object_id INT;
DECLARE @change_table_name NVARCHAR(MAX);
DECLARE @sqlCommand NVARCHAR(MAX);

SET @object_id = OBJECT_ID([TABLE NAME]);
SET @change_table_name = (SELECT TOP 1 name FROM sys.internal_tables where parent_object_id = @object_id);
SET @sqlCommand = N'EXEC sp_spaceused N''' + 'sys.' + @change_table_name + N'''';
EXEC sp_executesql @sqlCommand;