An Azure SQL Database has change tracking enabled on the database and on the table dbo.Customers. The database has a change tracking retention period of two days. dbo.Customers has a primary key, but it has no column that records when a row was last modified.
A full initial load of dbo.Customers has been completed. Before that load, the value returned by CHANGE_TRACKING_CURRENT_VERSION() was saved as a baseline in a version table.
You are designing a nightly job that has the following requirements:
- Each run copies only the delta data for inserts, updates and deletes since the previous run.
- Each run must begin from the point where the previous run ended.
What should each nightly run do?
Each incremental run reads the stored version and captures the current version. It copies the delta data between those boundaries, including change information for deletions, then saves the captured current version. This advances the baseline for the next run while avoiding a complete table copy.
- Not correct: Copy all rows from dbo.Customers, then save the current version as the stored version. The source uses a complete table copy for the initial load. Repeating that copy violates the requirement to copy only delta data.
- Correct: Read the stored and current versions, copy delta data between them, then save the current version as the stored version. The source describes reading the old and new change tracking versions, copying the delta data between them, and updating the stored version for the next run.
- Not correct: Read the stored and current versions, copy delta data between them, then leave the stored version unchanged. The source updates the stored version for the next run. Leaving it unchanged makes subsequent runs continue from the original baseline rather than the previous run's endpoint.
- Not correct: Copy rows whose modification time is later than the previous run, then save the current run time. The scenario provides no modification-time column. The source describes change tracking as a way to identify delta data when timestamp-based selection is unavailable.