0

I would like to call a stored procedure for each row returned in a database view and pass values from the row to the stored procedure. Note that the data within the view does NOT contain an ID column (or any unique column).

I see that using cursors and WHILE loops aren't recommended.

Does anyone have an example they can share?

Leandro Bardelli
  • 10,561
  • 15
  • 79
  • 116
  • Would it be possible to not pass values into a procedure, but rather have the procedure select and manipulate data within itself? This would be the optimal approach. – Jaaz Cole May 28 '14 at 15:46
  • Unfortunately, I cannot modify the stored procedure as it is supplied by a commercial piece of software and I do not want to alter it in anyway. – user3684136 May 28 '14 at 17:58
  • Then your only option is a cursor. – Jaaz Cole May 28 '14 at 18:15
  • Thank you Jaaz. I ended up using a WHILE loop to call the stored procedure for each record in the view and I used ROW_NUMBER() to provide a unique identifier for each row in the view. – user3684136 May 29 '14 at 13:53

0 Answers0