'selection from query runs before the ENABLE CHANGE_TRACKING in IF NOT EXISTS clause

I am running this query

IF NOT EXISTS (SELECT 1 FROM sys.change_tracking_tables 
               WHERE object_id = OBJECT_ID('Person.[Address]'))
BEGIN
    ALTER TABLE Person.[Address]
    ENABLE CHANGE_TRACKING  
    WITH (TRACK_COLUMNS_UPDATED = ON)  
END

SELECT 1 
FROM CHANGETABLE( CHANGES Person.[Address], 1) as E

I was expecting this would give me correct result, even if change tracking is disabled on table initially.

But I get this error instead:

Msg 22105, Level 16, State 1, Line 9
Change tracking is not enabled on table 'Person.Address'.

But when I run these queries separately, it works fine. Is there some asynchronous type nature in SQL?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source