SQL Server : call stored procedure with side effects for each row without using a cursor -


before identical sql call stored procedure each row without using cursor let me clarify question:

the stored procedure have side effects. in fact, it's side effects, results of each call influence further processing.

think of this: table contains rule definitions, , proc executes rules literally rbar, making changes table.

under conditions not see how set operation possible, cross apply can't used because of side effects, it's not needed, since i'm not joining rule table results.

if solution rbar, should still try avoid using cursor? using while read top 1 key > @key better solution? why?

the more searched, more came conclusion fast_forward read_only cursor simplest , fastest solution.

cursors inherently bad

no. cursors misused, , tend leapt upon people new sql because they're procedural background , haven't heard of "set-based". cursors have place, , if you've assessed available approaches , concluded cursors fit, i'd use one.

using while loop hide fact you're doing using cursor i'd recommend against.

one final note - mentioned fast_forward , read_only - 1 other recommendation local - way, if goes wrong, @ least cursor cleaned when exit whatever scope cursor running in - rather persisting lifetime of connection.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -