I'm working on SQL Server 2016 SP1 with the Change Tracking feature and I have a question for you.
I have a database which has Change Tracking enabled. That database contains a table Table
which has "change tracking" activated, but not "track columns updated" option.
For the example, on Table
, I only have one column called Id
of type is "uniqueidentifier", which is my PK.
On start, my change tracking current version is 0.
I got it with :
SELECT CHANGE_TRACKING_CURRENT_VERSION();
I added a new row to Table
:
INSERT INTO dbo.[Table] (Id)
VALUES ('C99F9E2A-1974-47CE-A406-481076F53BBD');
Now, my change tracking current version is now 1.
With this request, I can see my element in the change tracking system :
SELECT *
FROM CHANGETABLE (CHANGES dbo.[Table], 0) CT;
The result is :
Now, I delete my row with this :
DELETE FROM dbo.[Table]
WHERE Id = 'C99F9E2A-1974-47CE-A406-481076F53BBD';
Change tracking current version is now 2.
I insert it again with the same request than previous.
Change tracking current version is now 3.
With this request, I got this result :
SELECT *
FROM CHANGETABLE (CHANGES dbo.[Table], 1) CT;
Now is my question, why I got "U" in SYS_CHANGE_OPERATION ?
Why not "I" cause 1 < SYS_CHANGE_CREATION_VERSION which is 3 ?
Thanks for your help !