Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Update Trigger not always an update

Tags:

sql

triggers

So I've got a simple update trigger that copies the the deleted data into another table of the same format, with the addition of the modified date. It works great, however there are a lot of cases in the application code when an update is performed that doesn't actually change any values.

I'm trying to avoid these being picked up in the audit tables.

Does anybody have any suggestions on how I can fix this, without changing my application code. Possibly a simple comparison of the rows to check for changes?

Thanks

like image 774
mat-mcloughlin Avatar asked Aug 29 '26 07:08

mat-mcloughlin


1 Answers

Unfortunately, it is a column by column comparison in the trigger

Edit: for not guaranteed 100% accuracy, you can use CHECKSUM(*). HashBytes is better

like image 124
gbn Avatar answered Aug 30 '26 23:08

gbn