CDC捕获变更
1、对需要开启CDC的数据库:
user targetdb;
EXEC sys.sp_cdc_enable_db
(提示,当执行这步报错“执行命令 'SetCDCTracked(Value = 1)' 时失败”的话,先执行一下exec sp_changedbowner 'sa','dbo'即可解决)
2、检测是否开启:
Select [name] as DBName, is_cdc_enabled from sys.databases
3、对某个表启用CDC
EXEC sp_cdc_enable_table 'dbo', 'targettablename', @role_name = NULL, @supports_net_changes =1
4、检测是否开启
Select [name], is_tracked_by_cdc from sys.tables
对表进行UPDATE等操作后,可以到系统表中cdc.xxxxxx相关表中找到。