Setup SQL Server heartbeats for low and intermittent traffic databases
In low-traffic or intermittent databases, the log can become stale due to inactivity, which may cause the Connector to miss change events.To prevent this, the heartbeat process — which runs within the Connector — periodically inserts or updates a record in the heartbeat table. This triggers a change event, keeping the logs active and ensuring that all changes are detected and captured by the Connector.
-- Create the heartbeat table with id, text, and last_update fieldsCREATE TABLE streamkap.streamkap_heartbeat ( id INT IDENTITY(1,1) PRIMARY KEY, text NVARCHAR(MAX), last_update DATETIME2 DEFAULT SYSUTCDATETIME());-- Enable change tracking on the heartbeat tableEXEC sys.sp_cdc_enable_table@source_schema = N'streamkap',@source_name = N'streamkap_heartbeat',@role_name = N'streamkap_role',@filegroup_name = N'Streamkap_ChangeTracking', -- Not applicable for Azure SQL Databases@supports_net_changes = 0GO-- Grant permission on the heartbeat table to the Streamkap roleGRANT SELECT, INSERT, UPDATE ON streamkap.streamkap_heartbeat TO streamkap_role;-- Insert the first row into the heartbeat tableINSERT INTO streamkap.streamkap_heartbeat (text) VALUES ('test_heartbeat');