Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Updating changes to two tables using T-SQL

I have a webform contains a list of documents and information about them. What would be the best way to update any changes back to the database where I would need to log each change into an audit table as well.

For example:

document changed
A Yes
B No
C Yes

I would need to take this information and update the documents table with the changes from A and C, but ALSO would need TWO entries in my audit log table. One for A and one for C. Is there a quick way to do this or will I need to use loops and/or cursors? I'm trying to find a way that won't kill my performance. Thank you.
[665 byte] By [Billkamm] at [2007-11-11 7:49:43]
# 1 Re: Updating changes to two tables using T-SQL
A trigger is probably the best method to audit changes.
Wiseman82 at 2007-11-11 23:47:37 >
# 2 Re: Updating changes to two tables using T-SQL
I would advise you to enclose it in a transaction and do the updates into the two tables within the transaction
Thats what i do
srinivas_s at 2007-11-11 23:48:37 >