CDC functionality for SQL Server 2008

Source: Internet
Author: User
Tags insert

The CDC (change data Capture) records the time, type, and actual data changes of the DML operation by asynchronously reading the transaction log, and then logs the data to a table that is automatically created when the CDC is enabled. Detailed data changes can be obtained through CDC-related stored procedures. Because the data change is read asynchronously, it has little effect on the overall performance, much less than the data change record implemented by trigger.

I'll explain this feature in an example below. This feature is primarily useful in ETL solutions.

Use AdventureWorksDW;
Go
EXECUTE sys.sp_cdc_enable_db--enable the database to support the CDC
go
EXEC sys.sp_cdc_enable_table ' dbo ',
' FactInternetSales ', @role_name = NULL, @supports_net_changes = 0; --enable a table to support the CDC go--
Here's supports_net_changes refers to whether or not to support the so-called net change, that is, to filter out duplicate
SELECT name, IS_TRACKED_BY_CDC From Sys.tables
WHERE name like (' fact% ');
INSERT into FactInternetSales
VALUES

(484,1127,1139,1134,18759,1,100,6, ' SO75124 ', 1,1,1,21.9800,21.9800,0,0,8.2205,8.2205,21.9800,

1.7584,0.5495,null,null);
INSERT into FactInternetSales
VALUES

(486,1127,1139,1134,18759,1,100,6, ' SO75125 ', 1,1,1,21.9800,21.9800,0,0,8.2205,8.2205,21.9800,

1.7584,0.5495,null,null);
UPDATE FactInternetSales
SET Promotionkey = 2
WHERE salesordernumber = ' SO75124 ';
DELETE from FactInternetSales WHERE salesordernumber= ' SO75125 '
SELECT * from CDC.DBO_FACTINTERNETSALES_CT; --the table is actually in the system table.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.