Discussion Locked

Ms Sql Server problem

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I created a table which is about to have 100 records now.There are actually 2 triggers linked to that table whenever the user make a update.
My problem is that when a update on multiple rows is made,the triggers are fired although an error raise which conclude to a end of statement.
Is there anybody who already dealt with such a problem ?

4 replies

by xmldeveloper

We use triggers for audit purposes and custom replication. Review your code and see what's causing the error when you have multiple rows.

by pakman

In your trigger you must specifically account for a multirow update situation. Depending on what your trigger code does, you may need to use some sort of aggregate function in the select statement of your subquery. You can also test @@ROWCOUNT in the trigger to see if a single row or multiple rows have been updated so you can code for a single row, or the aggregate for multiple rows.

by lelerew

Can you check, at the beginning of your trigger to see if an error condition exists and then take appropriate action or quit?

AND, YES, remeber that the trigger fires after the query and only once for multiple updates.

by softwareguru

It would help if you list the table structure and the triggers. The trigger logic should assume that there are more than one rows being updated

This discussion is closed to new replies.