我刚刚使用以下脚本恢复了我的数据库,
USE [master]
GO
RESTORE DATABASE [MyDB]
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLSTANDARD\MSSQL\Backup\mydb.bak' WITH FILE = 1,
NOUNLOAD, REPLACE, STATS = 5, KEEP_CDC
GO
USE MyDB
GO
EXECUTE sys.sp_cdc_add_job 'capture';
GO
EXECUTE sys.sp_cdc_add_job 'cleanup';
GO
然后我查了CDC,
select is_tracked_by_cdc,name from sys.tables order by is_tracked_by_cdc desc
select is_cdc_enabled,name from sys.databases order by is_cdc_enabled desc
为我的表启用了 CDC。然后我运行更新脚本,
UPDATE MyTable SET Name='SomeName' where id=1
但发现cdc表中没有记录,
SELECT * FROM [cdc].[dbo_MyTable_CT]
我已安装最新的累积更新 (CU31)。