How to traverse lines of a SELECT in a STORED PROCEDURE in SQL Server?

Asked

Viewed 900 times

2

Other than with the use of CURSOR and WHILE in the SQL Server, what other ways it would be possible to traverse the result lines of a SELECT in a STORED PROCEDURE?

  • 1

    more information about what you want to do? the two best ways to go through the records are while and cursor, each should be used in a situation..

1 answer

5


Apart from CURSOR and WHILE I don’t believe there’s any other way.

On the Oracle we have a FOR loop, but this does not exist in SQL Server. However I do not see the real need to have even more ways to iterate a SELECT in addition to these two cases.

Iterate the results, even if using a CURSOR, I don’t think it’s a good idea anymore because it’s not performatic, imagine a WHILE or any other loop.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.