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.
精彩评论