Hi everybody,
I have a table where on a single record update, a trigger adds a history record in another table.
When I run a multiple record update on the table the trigger does not work since it was implemented to work with only one record and a trigger runs only once for a statement regardless if it affects multiple records. Is there a way to make this work?
Can I use the following check:
**if @@rowcount = 1**
in order to handle a single record in the way it is handled now and in the else statement to handle it in another way(which I do not know)?
The problem is how can I handle each case atomically when I have multiple records and how can I take every each record from the INSERTED table?
The trigger currently initializes some variables from the INSERTED table, updates the datetime column on the same table and then attempts to insert a history record using the initialized variables I mentioned earlier. So these are the steps I would like to have supporting multiple records.
Can anybody provide me with a simple example or guidelines?
Thank you in advance