SQL Server change tracking
No edit summary
Line 10: Line 10:


====== See also when implementing ======
====== See also when implementing ======
https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/work-with-change-tracking-sql-server
Article with a lot of details: https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/work-with-change-tracking-sql-server


Setting Context Information provides a way to know that the MDrivenServer is the source of the change
Setting ''Context Information'' provides a way to know that the MDrivenServer is the source of the change


Maybe '''last_synchronization_version''' can be used to know if ANY change has occured
Maybe '''last_synchronization_version''' can be used to know if ANY change has occured

Revision as of 13:50, 12 April 2018

Tracking of changes is available from Sql Server 2008 and in Azure SQL. It's available in the Express editions, so you can use it in the build in Turnkey database.

To turn change tracking On, do like this

ALTER DATABASE AdventureWorks2012  
SET CHANGE_TRACKING = ON  
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON) 
More reading

https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/about-change-tracking-sql-server

See also when implementing

Article with a lot of details: https://docs.microsoft.com/en-us/sql/relational-databases/track-changes/work-with-change-tracking-sql-server

Setting Context Information provides a way to know that the MDrivenServer is the source of the change

Maybe last_synchronization_version can be used to know if ANY change has occured

-- Check all tables with change tracking enabled  
IF EXISTS (
    SELECT COUNT(*) FROM sys.change_tracking_tables
    WHERE min_valid_version > @last_synchronization_version )
  BEGIN
    -- Handle invalid version & do not enumerate changes
    -- Client must be reinitialized
  END
This page was edited 47 days ago on 03/26/2024. What links here