What causes the minimum valid version to be greater than the current version when using sql server change tracking?

1.6k Views Asked by At

I'm using sql server change tracking and I noticed some unexpected behavior that doesn't seem to be documented.
The documentation indicates that the value returned by CHANGE_TRACKING_MIN_VALID_VERSION ( table_object_id ) should be compared against the last sync version before using the changes returned by the ChangeTable. This makes sense so I coded my sync process to make this check and then stored the values return by calling CHANGE_TRACKING_CURRENT_VERSION. Here is the documentation I referenced.

The next time I ran the sync process it compared the two values and again the min valid version was greater than the last sync version. After troubleshooting I realized that the current version returned by CHANGE_TRACKING_CURRENT_VERSION was actually less than the min valid version.

Is this expected behavior? I can certainly work around it by storing the min valid version if it's greater than the current version. I did notice that the current version was incremented as soon as a change was made to a table that had change tracking enabled. This could be only an issue in a dev environment since the database I'm using is seldom changing. I just want to make sure I'm not missing something.

0

There are 0 best solutions below