|
|
Question : foreach statement in TSQL
|
|
Is there such thing as a foreach statement in TSQL? or is a cursor the only option here?
I want to itterate through a small result set and it would be nice to have something more susinct than a cursor.
|
Answer : foreach statement in TSQL
|
|
You can do a while loop as well (better than cursor). Or better still have the logic in a function. It depends on what you are trying to achieve. Essentially, any time that you can avoid loops and perform set-based operations you will improve performance.
What are you trying to do?
|
|
|
|