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.
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.
You can use this query:
SELECT * FROM sys.change_tracking_databases WHERE database_id=DB_ID('MyDatabase')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With