Using Cursors to Solve Multirow Actions in Triggers

In many cases, dealing with multirow operations inside triggers is not an easy task. If the single-row solution is solved, you can use cursors to convert multirow operations into single-row operations inside the trigger, to apply to them the same proved logic of the single-row cases.

Consider the following example: You want to assign a credit limit to every customer following an automated process applied by the AssignCreditLimit stored procedure. To automate the process, you can create a trigger AFTER INSERT to calculate the credit limit for every new customer.

The AssignCreditLimit stored procedure can work with only one customer at a time. However, an INSERT operation can insert multiple rows ...

Get Microsoft® SQL Server™ 2000 Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.