O'Reilly logo

Microsoft® SQL Server™ 2000 Programming by Example by Carlos Eduardo Rojas, Fernando G. Guerrero

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required