开发者

Can I: loop through sql select and then fire off for each loop?

开发者 https://www.devze.com 2023-01-19 09:56 出处:网络
I\'m probably missing something (looking at it too long), but in a stored procedure can I select all distinct values from one tab开发者_运维百科le and then do a for each loop based on each of those re

I'm probably missing something (looking at it too long), but in a stored procedure can I select all distinct values from one tab开发者_运维百科le and then do a for each loop based on each of those returned rows, which themselves build up sql statements based on the distinct values?

Cheers.


Yes, you can use a cursor.

Note that cursors are best avoided if possible. If it's possible to do what you need with a set-based query -- and it often is -- then you should do that instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消