You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/relational-databases/system-stored-procedures/sys-sp-flush-ct-internal-table-on-demand-transact-sql.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,8 +87,8 @@ Service Pack 4 for SQL Server 2012
[!INCLUDE [SQL Server Azure SQL Database Azure SQL Managed Instance](../../includes/applies-to-version/sql-asdb-asdbmi.md)]
24
25
25
26
Change tracking is a lightweight solution that provides an efficient change tracking mechanism for applications. Typically, to enable applications to query for changes to data in a database and access information that is related to the changes, application developers had to implement custom change tracking mechanisms. Creating these mechanisms usually involved a lot of work and frequently involved using a combination of triggers, **timestamp** columns, new tables to store tracking information, and custom cleanup processes.
- The fact that a row has changed and information about the change must be available and recorded at the time that the change was made in the same transaction.
38
39
39
40
> [!NOTE]
40
-
> If an application requires information about all the changes that were made and the intermediate values of the changed data, using change data capture, instead of change tracking, might be appropriate. For more information, see [About Change Data Capture (SQL Server)](../../relational-databases/track-changes/about-change-data-capture-sql-server.md).
41
+
> If an application requires information about all the changes that were made and the intermediate values of the changed data, using change data capture, instead of change tracking, might be appropriate. For more information, see [About Change Data Capture (SQL Server)](../../relational-databases/track-changes/about-change-data-capture-sql-server.md).
41
42
42
-
## One-Way and Two-Way Synchronization Applications
43
+
## One-Way and Two-Way Synchronization Applications
44
+
43
45
Applications that have to synchronize data with an instance of the [!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)] must be able to query for changes. Change tracking can be used as a foundation for both one-way and two-way synchronization applications.
44
46
45
-
### One-Way Synchronization Applications
47
+
### One-Way Synchronization Applications
48
+
46
49
One-way synchronization applications, such as a client or mid-tier caching application, can be built that use change tracking. As shown in the following illustration, a caching application requires data to be stored in the [!INCLUDE[ssDE](../../includes/ssde-md.md)] and to be cached in other data stores. The application must be able to keep the cache up-to-date with any changes that have been made to the database tables. There are no changes to pass back to the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
Two-way synchronization applications can also be built that use change tracking. In this scenario, the data in an instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)] is synchronized with one or more data stores. The data in those stores can be updated and the changes must be synchronized back to the [!INCLUDE[ssDE](../../includes/ssde-md.md)].
The two-way synchronization applications must be able to detect conflicts. A conflict would occur if the same data was changed in both data stores in the time between synchronizations. With the ability to detect conflicts, an application can make sure that changes are not lost.
58
62
59
-
## How Change Tracking Works
63
+
## How Change Tracking Works
64
+
60
65
To configure change tracking, you can use DDL statements or [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)]. For more information, see [Enable and Disable Change Tracking (SQL Server)](../../relational-databases/track-changes/enable-and-disable-change-tracking-sql-server.md). To track changes, change tracking must first be enabled for the database and then enabled for the tables that you want to track within that database. The table definition does not have to be changed in any way, and no triggers are created.
61
66
62
67
After change tracking is configured for a table, any DML statement that affects rows in the table will cause change tracking information for each modified row to be recorded. To query for the rows that have changed and to obtain information about the changes, you can use [change tracking functions](../../relational-databases/system-functions/change-tracking-functions-transact-sql.md).
63
68
64
69
The values of the primary key column is only information from the tracked table that is recorded with the change information. These values identify the rows that have been changed. To obtain the latest data for those rows, an application can use the primary key column values to join the source table with the tracked table.
65
70
66
71
Information about the change that was made to each row can also be obtained by using change tracking. For example, the type of DML operation that caused the change (insert, update, or delete) or the columns that were changed as part of an update operation.
67
-
72
+
68
73
## Change Tracking Cleanup
74
+
69
75
Change tracking information for all tables (enabled for Change Tracking) is stored in an in-memory rowstore. Change tracking data associated with each table enabled for Change Tracking is flushed on every checkpoint from the in-memory rowstore to the corresponding on-disk internal table. During checkpoint, the in-memory rowstore is also purged after the rows are moved to the on-disk tables.
70
76
71
77
Each table that is enabled for Change Tracking has an internal on-disk table which is used by Change Tracking functions to determine the change version and the rows that have changed since a particular version. Every time the **auto cleanup** thread wakes up, it scans all the user databases on the SQL Server instance to identify the change tracking enabled databases. Based on the retention period setting of the database, each internal on-disk table is purged of its expired records.
72
78
73
79
A stored procedure was added in Service Packs for [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)] and [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] for performing manual cleanup for the internal Change Tracking internal tables. More information about the stored procedure is available in [KB173157](https://support.microsoft.com/help/3173157/adds-a-stored-procedure-for-the-manual-cleanup-of-the-change-tracking-side-table-in-sql-server-2014-sp2-or-2016-sp1).
74
80
75
-
## See Also
81
+
## See Also
82
+
76
83
[Enable and Disable Change Tracking (SQL Server)](../../relational-databases/track-changes/enable-and-disable-change-tracking-sql-server.md)
77
84
[Work with Change Tracking (SQL Server)](../../relational-databases/track-changes/work-with-change-tracking-sql-server.md)
Copy file name to clipboardExpand all lines: docs/relational-databases/track-changes/cleanup-and-troubleshooting-change-tracking-sql-server.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,8 @@ The sp_flush_CT_internal_table_on_demand stored procedure will do the following:
69
69
70
70
## Creating Extended Events for Change Tracking
71
71
72
-
Note: Extended Events Are Not Available With Azure SQL Database
72
+
> [!NOTE]
73
+
> Extended Events Are Not Available With Azure SQL Database
73
74
74
75
[Extended Events](../../relational-databases/extended-events/extended-events.md) can be used for monitoring and alerting with Change Tracking and can be created with [SQL Server Management Studio (SSMS)](../../relational-databases/extended-events/quick-start-extended-events-in-sql-server.md).
0 commit comments