CDC change data capture

Source: Internet
Author: User

CDC change data capture(2013-03-20 15:25:52)
Category: SQL

four ways to record data changes in SQL Server: Trigger, OUTPUT clause, change data capture feature, synchronous change tracking.

The CDC is recorded here: change data Capture records INSERT, UPDATE, and delete activities that are applied to SQL Server tables. Enable change data capture for a table in the database, example: CREATE DATABASE test1 Use test1CREATE TABLE [dbo]. [WSTTESTTBL] ([id] [int] IDENTITY (*) not NULL,[name] [nvarchar] (+) NULL) on [PRIMARY] sp_cdc_enable_db--Enable change data capture for the current databaseSELECT is_cdc_enabled from sys.databases WHERE name= ' test1 '--enable change data capture for database success sp_cdc_enable_table @source_schema = ' dbo ', @source_name = ' wsttesttbl ', @role_name = ' cdc_role '-the table identified by the source table as a tracked ( Condition: Start SQLServerAgent service)  --execute sys.sp_cdc_help_change_data_capture--Change data capture configuration information for a specified table--@source_schema = N ' dbo ',--@source_name = N ' wsttesttbl ';--go INSERT into WSTTESTTBL values (' Jiayiw ')Delete from wsttesttbl WHERE name = ' Jiayiw 'INSERT into WSTTESTTBL values (' wangshuting ')UPDATE wsttesttbl SET name= ' Zhangjie ' WHERE name= ' wangshuting '--select * from WsttesttblSELECT * from Cdc.dbo_wsttesttbl_ct --__$operation=2, indicates a new--__$operation=3 or 4, indicating an update, 3 representing the old value, and 4 representing the new value--__$operation=1 of the situation, indicating the deletion 

In addition, you can use CDC to implement incremental loading (SSIS)

CDC change data capture

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.