Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sql ChangeTracking clean up tables

When using Sql 2008 Change Tracking is there a way to manually clean up the tracking tables?

I know about the CHANGE_RETENTION and AUTO_CLEANUP properties but would perfer more control over the cleanup.

like image 314
Tyler Avatar asked Jun 20 '11 18:06

Tyler


People also ask

How do you track changes in a table in SQL?

Right click on the table you want to track changes. Click Properties, click Change Tracking, then in the right pane set Change Tracking to TRUE.

How do you track data changes in a database table?

At the basic database level you can track changes by having a separate table that gets an entry added to it via triggers on INSERT/UPDATE/DELETE statements. Thats the general way of tracking changes to a database table. The other thing you want is to know which user made the change.

Can SQL track changes?

SQL Server provides two features that track changes to data in a database: change data capture and change tracking. These features enable applications to determine the DML changes (insert, update, and delete operations) that were made to user tables in a database.

How do I enable change tracking in SQL table?

You can also enable change tracking in SQL Server Management Studio by using the Database Properties (ChangeTracking Page) dialog box. If a database contains memory optimized tables, you can't enable change tracking with SQL Server Management Studio. To enable, use T-SQL.


1 Answers

Basically these Change Tracking information are stored in Internal Tables and no option to clean up manually. But still we can clear by disabling/enabling change tracking for a tables.

alter table <tableName> disable change_tracking  
alter table <tableName> enable change_tracking  

THis command will clean up all change tracking related to specific table.

like image 164
Gunarathinam Avatar answered Oct 07 '22 07:10

Gunarathinam