Using Change Data Capture (CDC) in SQL Server 2008

Problem As we are looking through the new features in SQL Server 2008 we found a potentially interesting one called Change Data Capture. Can you give us a detailed explanation of how we go about using this one? Solution Change Data Capture

problem
as we are looking through the new features in sql server 2008 we found a potentially interesting one called change data capture.  can you give us a detailed explanation of how we go about using this one?

Solution
Change Data Capture is a new feature in SQL Server 2008 that records insert, update and delete activity in SQL Server tables.  A good example of how this feature can be used is in performing periodic updates to a data warehouse.  The requirement for the extract, transform, and load (ETL) process is to update the data warehouse with any data that has changed in the source systems since the last time the ETL process was run.  Before CDC we might simply query a last updated DATETIME column in our source system tables to determine what rows have changed.  While this is simple and pretty effective, it is of no use in determining any rows that were physically deleted.  In addition we can’t determine what was changed when; we can only access the current state of a row that has changed.  CDC provides a configurable solution that addresses these requirements and more.

In this tip we are going to gain an understanding of CDC by walking through a simple code sample to demonstrate how to:

Setup and configure CDCUse CDC to extract rows that have been inserted, updated, or deleted via T-SQL queries

Before we start reviewing the sample T-SQL code, let’s discuss how CDC works at a high level.  After performing some setup and configuration steps (which we will cover below), CDC will begin scanning the database transaction log for changes to certain tables that you specify, and will insert these changes into change tables.  These change tables are created during the setup and configuration process.  The setup and configuration process will also create table-valued functions which can be used to query for the changes.  You use the table-valued functions in lieu of querying the underlying change tables directly.  Based on this high level description, let’s proceed to the demo.

The demo code below was only tested on the February, 2008 Community Technology Preview (CTP) of SQL Server 2008.  Some of the function names and stored procedure names have changed from the earlier CTPs.

Setup and Configuration

CDC is a feature that must be enabled at the database level; it is disabled by default.  To enable CDC you must be a member of the sysadmin fixed server role.  You can enable CDC on any user database; you cannot enable it on system databases.  Execute the following T-SQL script in the database of your choice to enable CDC:

declare @rc intexec @rc = sys.sp_cdc_enable_dbselect @rc– new column added to sys.databases: is_cdc_enabledselect name, is_cdc_enabled from sys.databases

,网站空间,香港服务器,美国服务器

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/1844209.html

(0)
上一篇 2025年2月22日 00:28:47
下一篇 2025年2月22日 00:29:02

AD推荐 黄金广告位招租... 更多推荐

相关推荐

  • jquery中data()和attr()的区别是什么

    区别:“$.attr()”每次都从DOM元素中取属性的值,即和视图中标签内的属性值保持一致;而“$.data()”是从Jquery对象中取值,由于对象属性值保存在内存中,和视图中的属性值不一定一致。 本教程操作环境:windows7系统、j…

    2025年3月11日
    200
  • vue里data为什么要用return返回数据

    原因:不使用return包裹的数据会在项目的全局可见,会造成变量污染;而使用return包裹后数据中变量只在当前组件中生效,不会影响其他组件。 本教程操作环境:windows7系统、vue2.9.6版,DELL G3电脑。 官方: 当一个组…

    2025年3月11日
    200
  • ajax()中data参数是什么意思

    在ajax中,data的意思为“数据”,该参数用于规定要发送到服务器的数据,会将数据自动转换为请求字符串格式;如果是GET请求,就会将要发送数据附加在URL后。 本教程操作环境:windows7系统、jquery1.10.2版本、Dell …

    2025年3月11日
    200
  • html5自定义属性什么用

    html5自定义属性“data-*”用于存储私有页面后应用的自定义数据,而自定义的数据可以让页面拥有更好的交互体验(不需要使用Ajax或去服务端查询数据),语法“”;“data-*”属性由两部分组成:1、属性名不要包含大写字母,在“data…

    2025年3月11日
    200
  • vue组件中data不能是函数吗

    不是,vue组件中data必须是一个函数。vue中组件是用来复用的,为了防止data复用,将其定义为函数。vue组件中的data数据都应该是相互隔离,互不影响的,组件每复用一次,data数据就应该被复制一次,之后,当某一处复用的地方组件内d…

    2025年3月11日 编程技术
    200
  • html5的自定义data-*属性与jquery的data()方法的使用_html5教程技巧

    人们总喜欢往HTML标签上添加自定义属性来存储和操作数据。但这样做的问题是,你不知道将来会不会有其它脚本把你的自定义属性给重置掉,此外,你这样做也会导致html语法上不符合Html规范,以及一些其它副作用。这就是为什么在HTML5规范里增加…

    编程技术 2025年3月11日
    200
  • HTML5的data-*自定义属性是什么

    HTML5的data-*自定义属性 html5增加了一项新功能是自定义数据属性,也就是data-*自定义属性。在html5中我们可以使用以data-为前缀来设置我们需要的自定义属性,来进行一些数据的存放。当然高级浏览器下可通过脚本进行定义和…

    编程技术 2025年3月11日
    200
  • 如何使用HTML5中的data-*属性

    HTML5中的data-属性主要用于存储页面中的私有自定义数据,目的是为了创建更好的用户体验 HTML中新增了许多新的属性,今天将要介绍HTML5中的data-* 属性,希望对大家有所帮助。 【推荐课程:HTML5课程】 立即学习“前端免费…

    2025年3月9日
    200
  • ajax请求data会遇到哪些问题

    这次给大家带来ajax请求data会遇到哪些问题,ajax请求data的注意事项有哪些,下面就是实战案例,一起来看一下。 使用jquery,post请求data:那里要使用data:JSON.stringify(data) $.ajax({…

    编程技术 2025年3月8日
    200
  • 详解在Vue组件中的data为什么只能返回函数

     通过Vue构造器传入的各种选项大多数都可以在组件里用,唯独只有data选项有区别,在Vue构造器中data返回的是对象,但是在组建中必须返回一个函数。why?这篇文章主要介绍了详解在Vue组件中的data为什么只能返回函数,小编觉得挺不错…

    编程技术 2025年3月8日
    200

发表回复

登录后才能评论