Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


Returns the minimum version that is valid for use in obtaining change tracking information from the specified table, when you are using the CHANGETABLE function.

Topic link iconTransact-SQL Syntax Conventions



Is the object ID of the table. table_object_id is an int.

Use this function to validate the value of the last_sync_version parameter for CHANGETABLE. If last_sync_version is less than the value that is reported by this function, the results that are returned from a later call to CHANGETABLE might not be valid.

CHANGE_TRACKING_MIN_VALID_VERSION uses the following information to determine the return value:

  • When the table was enabled for change tracking.

  • When the background cleanup task ran to remove change tracking information older than the retention period specified for the database.

  • If the table was truncated. This removes all change tracking information that is associated with the table.

The function returns NULL if any one of the following conditions is true:

  • Change tracking is not enabled for the database.

  • The specified table object ID is not valid for the current database.

  • Insufficient permission to the table specified by the object ID.

The following example determines whether a specified version is a valid version. The example obtains the minimum valid version of the dbo.Employees table, and then compares this to the value of the @last_sync_version variable. If the value of @last_sync_version is lower than the value of @min_valid_version, the list of changed rows will not be valid.


You would usually obtain the value from a table or other location where you stored the last version number that was used to synchronize data.

-- The tracked change is tagged with the specified context 
DECLARE @min_valid_version bigint, @last_sync_version bigint;
SET @min_valid_version = 
SET @last_sync_version = 11
IF (@last_sync_version < @min_valid_version)
-- Error � do not obtain changes
-- Obtain changes using CHANGETABLE(CHANGES ...)

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft