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.
SELECT s.name AS Schema_Name, tb.name AS Table_Name , tb.object_id, tb.type, tb.type_desc, tb.is_tracked_by_cdc FROM sys.tables tb INNER JOIN sys.schemas s on s.schema_id = tb.schema_id WHERE tb.is_tracked_by_cdc = 1
– Lands