Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if change tracking is enabled

I'm trying to determine if Change Tracking is already enabled on my database before I run the ALTER DATABASE command to enable it. I am trying to prevent errors with these scripts if run multiple times.

I checked in sys.databases and sys.dm_tran_commit_table but was unable to find what I was looking for.

like image 688
Adam Wenger Avatar asked Apr 16 '12 18:04

Adam Wenger


People also ask

Which SQL statement is used for changing tracking number?

To configure change tracking, you can use DDL statements or SQL Server Management Studio. For more information, see Enable and Disable Change Tracking (SQL Server). 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.


1 Answers

You can use this query:

SELECT *  FROM sys.change_tracking_databases  WHERE database_id=DB_ID('MyDatabase') 
like image 148
Lamak Avatar answered Oct 06 '22 08:10

Lamak