December 8, 2017 at 1:00 pm
Comments posted to this topic are about the item Trigger Based Change Data capture
December 22, 2017 at 7:38 am
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.
December 22, 2017 at 10:08 am
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.
December 22, 2017 at 5:42 pm
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
Change is inevitable... Change for the better is not.
September 9, 2021 at 9:56 pm
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.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply