Trigger Based Change Data capture

  • Comments posted to this topic are about the item Trigger Based Change Data capture

  • This is good that you've shared this script. Thank you for that.
    I think it would also be very helpful, if you can point out the shortcomings of synchronous data change tracking solution with triggers. Especially in a highly trans/sec OLTP environment. And also how BULK operations can be affected as well. At least link some articles that have already been written on this topic. This can help with the decision making process.

  • It would be good to be aware of what newer constructs you are using that will limit the backward-compatibility of your solution.  CURRENT_TRANSACTION_ID only exists in SQL Server 2016, and IIRC, "CREATE OR ALTER" was added recently too (SQL Server 2013?).  This drastically limits your target audience, unless you re-code your solution to be applicable to older versions.  Some shops won't even see 2016 until well after 2020.

  • I could be wrong (I won't load this code to test it) but this appears to record not only data that has changed, but also records data in all of the other columns that hasn't changed and it records meta-data about each column in the table as well as some constraint meta-data, and it looks like somewhere between 300 and 400 bytes (can't tell for sure because it's a graphic rather than text) were created for the JSON "Payload" for what?  To audit that a single character was added to a single value during an update?

    --Jeff Moden

    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Minor bug in update trigger. Should be

    AND (SUBSTRING( COLUMNS_UPDATED(), ((column_id-1) / 8) +1,1) & power(2, (((column_id - 1 ) % 8) + 1) - 1)) > 0

    This can also be used to log only the modified fields

    Thanks. After modification, it is useful for small light duty databases where table structure is fairly static.



    • This reply was modified 2 years, 8 months ago by  rustyns. Reason: failed attachment
    You must be logged in to view attached files.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply