How to remove columns from CDC (in SQL Server)

大憨熊 提交于 2020-01-06 19:31:18

问题


I've enabled CDC on a table, using the code below, and by default it includes all of the columns. There is another way to enable CDC on a table while SPECIFYING the columns (code is given below). However, for me, that's too late - given my CDC was already created and includes ALL of the columns. How do I remove the columns I don't want from the CDC watch list (I searched everywhere in the meta data and couldn't find anything):

-- The following enabled the CDC on a table:
EXECUTE sys.sp_cdc_enable_table 
            @source_schema = N'dbo',
            @source_name = N'TableName',
            @role_name = N'cdc_Admin',  
            @supports_net_changes = 1

-- Now all of the columns are included in the CDC. 

--Alternate (which is too late now given my CDC on table was already created/performed)
EXECUTE sys.sp_cdc_enable_table      
@source_schema = N'dbo'    , 
@source_name = N'Orders'    , 
@role_name = N'cdc_Admin'    , 
@captured_column_list = N'OrderID,CustomerAccount,Product,SalesPerson'

回答1:


CDC allows you to have up to two capture instances active for a given table at the same time (in order to accommodate schema changes on the underlying table). So, in order to migrate to a new capture instance where you specify the columns (as you do in your second call to sys.sp_cdc_enable_table), provide a value for the @capture_instance parameter in sys.sp_cdc_enable_table and migrate your ETL jobs to use it. Then, once you're sure that nothing is using the old capture instance, drop it using sys.sp_cdc_disable_table again providing a value for @capture_instance (this time, the old one).




回答2:


In SSIS I can set the [CDC processing mode] on the CDC data source to 'Net with Update Mask' then see what columns were changed.

You could stage all the data and use the update mask to only process the changes you want to keep.



来源:https://stackoverflow.com/questions/29898661/how-to-remove-columns-from-cdc-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!