I m trying to capture DDL operations using CDC in SQLServer. I m able to capture DDl ops like add columns,drop columns and alter columns, but I m unable to capture below operations
- .add constraint or drop constraint, For example this SQL is not getting recorded,
alter table t add primary key(col1)
. - create,drop,rename table, for example
create table t(col1 int)
. ( I think this is understandable because a newly created table doesnt have cdc enabled by default so we are not getting the log, right?)
I m using cdc.ddl_history
table to see ddl logs.Does SQLServer doesnt support the above ddl logs. I tried searching online to find what all ddl are supported but I cant find any concrete information about this.
SQLServer version 2017 Developer Edition, OS - windows 10
Thanks
1条答案
按热度按时间o4hqfura1#
In SQL Server, the Change Data Capture (CDC) feature is primarily designed to capture data changes (DML operations) rather than DDL operations. While CDC can capture certain DDL operations, it has limitations and may not capture all DDL operations.
As @Nick mentioned, you can use DDL triggers to capture DDL events and perform custom actions in response to those events.