SQL Server DML Change Capture An overview of several useful SQL Server data change capture technologies Matt Smith Software Architect, Enterprise Data.

Slides:



Advertisements
Similar presentations
Your Data Any Place, Any Time Manageability. SQL Server 2008 Manageability Challenges Challenges face database administrators today : Managing complex.
Advertisements

By: Jose Chinchilla July 31, Jose Chinchilla MCITP: SQL Server 2008, Database Administrator MCTS: SQL Server 2005/2008, Business Intelligence DBA.
BY LECTURER/ AISHA DAWOOD DW Lab # 3 Overview of Extraction, Transformation, and Loading.
Module 8 Importing and Exporting Data. Module Overview Transferring Data To/From SQL Server Importing & Exporting Table Data Inserting Data in Bulk.
Module 12: Auditing SQL Server Environments
OVERVIEW TEAM5 SOFTWARE The TEAM5 software manages personnel and test data for personal ESD grounding devices. Test and personnel data may be viewed/reported.
Week 6: Chapter 6 Agenda Automation of SQL Server tasks using: SQL Server Agent Scheduling Scripting Technologies.
James Serra – Data Warehouse/BI/MDM Architect
SSIS Field Notes Darren Green Konesans Ltd. SSIS Field Notes After years of careful observation and recording of the Species SSIS, Genus ETL, in both.
Data Warehousing - 3 ISYS 650. Snowflake Schema one or more dimension tables do not join directly to the fact table but must join through other dimension.
Data Warehouse success depends on metadata
January 15, Tips for using SQL Server Change Data Capture (Introduction) The Baker’s Dozen Business Intelligence Webcast Radio 13 SQL Server -Business.
SQL Server 2005 SP2 Israeli SQL Server User Group March 2005 Ami Levin
ETL Design and Development Michael A. Fudge, Jr.
ETL By Dr. Gabriel.
Module 18 Monitoring SQL Server 2008 R2. Module Overview Monitoring Activity Capturing and Managing Performance Data Analyzing Collected Performance Data.
Course Topics Administering SQL Server 2012 Jump Start 01 | Install and Configure SQL Server04 | Manage Data 02 | Maintain Instances and Databases05 |
Performance Tuning SSIS. HR Departments are no fun. Don’t mention the stalking incident with Clay Aiken What happened in Vegas My prom date with a puppet.
Maintaining a Microsoft SQL Server 2008 Database SQLServer-Training.com.
SSIS Over DTS Sagayaraj Putti (139460). 5 September What is DTS?  Data Transformation Services (DTS)  DTS is a set of objects and utilities that.
Multiplicity – Progress Data Replication Methodologies.
Data Warehousing Seminar Chapter 5. Data Warehouse Design Methodology Data Warehousing Lab. HyeYoung Cho.
SQL Server 2008 for Developers John
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
DBSQL 14-1 Copyright © Genetic Computer School 2009 Chapter 14 Microsoft SQL Server.
1 Warranty and Repair Management For Infor XA Release 7 WARM Denise Luther – Sr. XA Consultant WARMS Technical Manager CISTECH, Inc. Rod Fortson – Sr.
Module 5 Planning for SQL Server® 2008 R2 Indexing.
Learningcomputer.com SQL Server 2008 – Administration, Maintenance and Job Automation.
IT 456 Seminar 5 Dr Jeffrey A Robinson. Overview of Course Week 1 – Introduction Week 2 – Installation of SQL and management Tools Week 3 - Creating and.
Triggers A Quick Reference and Summary BIT 275. Triggers SQL code permits you to access only one table for an INSERT, UPDATE, or DELETE statement. The.
Understanding SQL Server 2008 Change Data Capture Bret Stateham Training Manager Vortex Learning Solutions blogs.netconnex.com.
Module 16: Performing Ongoing Database Maintenance
LS Retail BI Information/requirements/deployment steps.
SQL Server 2005 Implementation and Maintenance Chapter 12: Achieving High Availability Through Replication.
1 Integration Services in SQL Server 2008 Allan Mitchell – SQLBits – Oct 2007.
Under New Management Andrew Fryer Microsoft UK Andrew Fryer Microsoft UK.
Transportation: Refreshing Warehouse Data Chapter 13.
SQL School is strongly committed to provide COMPLETE PRACTICAL REALTIME Trainings on SQL Server Technologies – Dev, SQL DBA, MSBI (SSIS, SSAS, SSRS) and.
Module 6: Data Protection. Overview What does Data Protection include? Protecting data from unauthorized users and authorized users who are trying to.
7 Strategies for Extracting, Transforming, and Loading.
02 | Data Flow – Extract Data Richard Currey | Senior Technical Trainer–New Horizons United George Squillace | Senior Technical Trainer–New Horizons Great.
IT System Administration Lesson 3 Dr Jeffrey A Robinson.
SQL SERVER AUDITING. Jean Joseph DBA/Consultant Contact Info: Blog:
Log Shipping, Mirroring, Replication and Clustering Which should I use? That depends on a few questions we must ask the user. We will go over these questions.
Helping Your Data Warehouse Succeed: 10 Mistakes to Avoid in Data Integration Rafael Salas w:
Building the Corporate Data Warehouse Pindaro Demertzoglou Lally School of Management Data Resource Management.
9 Copyright © 2004, Oracle. All rights reserved. Getting Started with Oracle Migration Workbench.
1 Copyright © 2005, Oracle. All rights reserved. Oracle Database Administration: Overview.
Agenda for Today  DATABASE Definition What is DBMS? Types Of Database Most Popular Primary Database  SQL Definition What is SQL Server? Versions Of SQL.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Database Design: Solving Problems Before they Start! Ed Pollack Database Administrator CommerceHub.
MANAGEMENT DATA WAREHOUSE AND DATA COLLECTOR Ian Lanham.
With Temporal Tables and More
Data Warehouse ETL By Garrett EDmondson Thanks to our Gold Sponsors:
Katowice,
Temporal Databases Microsoft SQL Server 2016
Temporal Databases Microsoft SQL Server 2016
Antonio Abalos Castillo
Death by 1000 changes An overview of several useful Microsoft SQL Server DML change capture technologies DML – Data manipulation language (compared to.
Example of a page header
Transactional Replication A Deeper Dive Drew Furgiuele, Senior DBA IGS
Hitting the SQL Server “Go Faster” Button
Traveling in time with SQL Server 2017
SQL Azure Database – No CDC, No Problem!
SQL SERVER 2014 Change Data Capture Dave Bland
Cloud Data Replication with SQL Data Sync
DAT381 Team Development with SQL Server 2005
Andrew Fryer Microsoft UK
Change Tracking Live Data Warehouse
T-SQL Tools: Simplicity for Synchronizing Changes Martin Perez.
Presentation transcript:

SQL Server DML Change Capture An overview of several useful SQL Server data change capture technologies Matt Smith Software Architect, Enterprise Data Warehouse Otter Products, LLC Denver, CO SQL Server User Group

Today’s Agenda Review three core SQL Server DML change capture technologies Custom T-SQL DML triggers SQL Server Change Tracking SQL Server Change Data Capture (CDC) Quick review of code exercises (time permitting)

Why capture data changes? Capturing changes is useful for solving common business problems Application auditing  “The sales team is deleting sales order lines instead of canceling them.“  “I think someone is deleting purchase order line information.” Business KPI’s & Customer metrics  Order Status change tracking (need to know the first date/time an order line went to status 77)  Did we hit our customer shipment targets? (monitor variance between promised and actual first shipment date) Data Warehousing/ETL Loading  Incremental data staging/data warehouse loading, intra-day reporting table updates  Infrastructure constraints (disk, network) Continuous Improvement Initiatives: cycle time  Monitoring process performance (ex. Key accounts return process, Customer warranty process)

Customer requirements: relevant to reporting & BI Our Goal: Clarify the problem(s) you are solving  Can you explain why we need capture data changes?  What decisions will you be making with this data?  Use Case: Can you explain how you are going to be using this data?  What are the metrics or KPI’s you are measuring?  How long do you want to retain this data? (negotiate)

Method #1: Custom DML Triggers Pros  Roll your own. Totally customizable and lots of options. It’s your logic  Compatible with any version of SQL Server (Express to Enterprise)  Track history of all or some changes (you choose)  No external processes/dependencies to worry about (SQL Agent Jobs, Capture Intervals, etc.)  Quick to implement. Code some triggers and go to lunch  Control sits firmly in dev team’s hands Cons  You must customize the source schema. You might not be able customize your databases as you may void your support contract  Trigger amnesia: Uh…oh yeah, I forgot about that trigger…mass data update took forever to run  High-transaction OLTP and triggers don’t get along: overhead, locking  Trigger proliferation and technical debt: Triggers are fun, we like to write triggers, now triggers are everywhere and it’s harder to change things Why DML Triggers? It’s because we are developers and that’s what we do! After Insert/Update/Delete triggers.

Method #2: SQL Server Change Tracking Pros  Definitively tells you that a column has changed over a specific range of DML statements  No customization of the source schema required (other than a PK).  Easy to determine rows that have changed, a little harder to determine cols that have changed  Included in SQL Server Standard edition (2008+)  A dev and ops collaboration for configuration and maintenance Cons  DML Change history not tracked. Change Tracking does not provide a sequential history of the changed values, just tells you that the value changed  Does not provide you with the time that the change occurred  Requires a Primary Key on the table for tracking changes. No heaps allowed  Requires significant coding and job scheduling to extract your changed data “Change tracking is a lightweight solution…”- msft

Method #3: SQL Server Change Data Capture (CDC) Pros  Does NOT require a primary key (supports heaps). exception: Net Changes TVF  No customization of the source schema required. CDC reads from the SQL Server transaction log and writes to CDC tables (uses sql server replication – run profiler and watch!)  Enable for all columns or for only a subset of columns  Useful functions and tracking tables based on time and Log Sequence number (LSN) ranges are built-in to help you extract change data  Basic SQL Server Data Tools SSIS Integration components for ETL processing are included (Attunity)  A dev and ops collaboration for configuration and maintenance Cons  SQL Server ENT edition ONLY (2008+)  You must be aware of transaction log management and HA/DR dependencies  SQL Agent required for capture and cleanup jobs, dbowner must be sa  CDC must be torn down and rebuilt in the event of transaction log database maintenance such as fixing VLF fragmentation or a Log Ship failover  Catch: DDL! For table DDL changes involving PK’s or unique indexes you may need to disable and re-enable CDC on the table. For Truncate (alter table DDL) - must disable CDC on the table first  Watch out for transaction log growth due to daily cleanup job (take smaller bites - schedule to run multiple times per day or limit with the threshold param)

Choosing a solution – quick review

Now that you have selected a technology, the real work begins. Working with the changed data is the majority of the effort and requires creative solutions.  Revisit your ETL pattern(s): Stage all changed data, apply changes as required to reporting tables and data warehouse staging tables  Change history tables grow quickly. Think about partitioning and trimming (deleting)  Consider data compression (PAGE) for change data destination tables, indexing and statistics updates for reporting tables (trace flag 2371)  Maintenance window changes: For Change Tracking and Change Data Capture, transaction log maintenance may lead to gaps in your change data  Recommendation: Avoid the Attunity SSIS CDC components. Use them to gain an understanding of how CDC works with SSIS for ETL, then create your own ETL solution Image:

Links and Contact This prezo along with demo code for Custom DML Triggers, Change Tracking and Change Data Capture is posted at |questions? Scripts: Useful Resources & References:  Change Tracking (Mike Byrd - Solarwinds) : tracking-bulletproof-etl-p1-mb01http://logicalread.solarwinds.com/sql-server-change- tracking-bulletproof-etl-p1-mb01  Change Data Capture:  SSIS CDC Components (Matt Masson – SSIS Team): for-sql-server / for-sql-server /  Special thanks for the peer review from