General discussion

Locked

Ms Sql Server problem

By percy_dom ·
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 ?

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by xmldeveloper In reply to Ms Sql Server problem

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

Collapse -

Multirow considerations

by pakman In reply to Ms Sql Server problem

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.

Collapse -

can you check for error condition?

by lelerew In reply to Ms Sql Server problem

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.

Collapse -

Post Example

by SoftwareGuru In reply to Ms Sql Server problem

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

Back to Software Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums