I made a typo in an update statement in our live environment this morning. It could have been a long day to fix it, as I blanked out a field in tx_cust_sal. While looking at the update trigger, I noticed that all changes are logged to ta_audit_trail. I wrote the script below to "rollback" the changes. I hope someone else finds this useful.
You'll need to change the datetime and other fields based upon your direct needs, so please don't run this as-is.
update tx_cust_salset esal1_desc = a.old_value from ta_audit_trail a, tx_cust_sal salwhere a.customer_no = sal.customer_noand a.table_name = 'tx_cust_sal'and a.date > '2009-09-29 09:00:00'and a.date < '2009-09-29 11:00:00'and a.action = 'updated'and a.column_updated = 'esal1_desc'and a.userid = 'dbo'and a.old_value is not nulland a.new_value is null
Well done. I've often though that ta_audit_trail would be a great source of "undo" data, but haven't yet used it for that myself. Someday, though, I'm sure...