How to fix Error 4998 on Windows Server 2025 / Windows 11

Troubleshooting Guide: Error 4998 — Change Tracking Not Enabled on Table

Why This Error Happens

This error occurs when a query or application attempts to retrieve change tracking data (via CHANGETABLE or similar functions) for a table that has not had change tracking explicitly enabled at the table level, even if it is enabled at the database level. This commonly happens after a table is recreated, renamed, or restored from backup, since change tracking settings are not always preserved during these operations. It can also occur if a user’s application code references a table name that no longer matches an actively tracked object due to a schema change.

Step-by-Step Resolution Guide

Step 1: Verify Database-Level Change Tracking Status

  • Open SQL Server Management Studio (SSMS) and connect to your Windows Server 2025 instance.
  • Run the following query to confirm change tracking is active at the database level:
SELECT * FROM sys.change_tracking_databases 
WHERE database_id = DB_ID('YourDatabaseName');
  • If no rows are returned, change tracking is not enabled on the database, and must be enabled first.

Step 2: Enable Change Tracking at the Database Level (If Missing)

  • Execute the following T-SQL command, replacing the database name as needed:
ALTER DATABASE YourDatabaseName
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON);
  • Confirm successful execution with no error messages returned in the Messages pane.

Step 3: Enable Change Tracking on the Specific Table

  • Run the targeted table-level command, substituting your schema and table name:
ALTER TABLE dbo.YourTableName
ENABLE CHANGE_TRACKING
WITH (TRACK_COLUMNS_UPDATED = ON);
  • Ensure the table has a defined Primary Key, as change tracking requires one to function correctly.

Step 4: Check for Object Recreation or Schema Drift

  • If the table was recently dropped and recreated, re-run Step 3, as table-level tracking settings do not survive a DROP TABLE command.
  • Check deployment scripts or ORM migrations (e.g., Entity Framework) to ensure they are not inadvertently dropping and recreating the table without re-enabling tracking.

Alternative or Verification Steps

  • Verify the fix by querying sys.change_tracking_tables and confirming your table’s object_id appears in the result set.
  • If the application error persists despite verification, restart the SQL Server service via services.msc on Windows Server 2025 to clear any stale metadata caching related to the Change Tracking feature.