Personally I'm not convinced a while loop is significantly better than a cursor. You'll use slightly less resources but it's still RBAR and a decent set based aproach will almost certainly give much better performance and hog less resource.
wiss.dev, I'm not sure I'm understanding your problem properly so maybe post the cursor you've got. It will make it easier to understand what you're trying to do. Here's a quick punt from what I think you're after though:-
That will give you all customers who have an order with a due quantity along with those orders. I've used an order by because you may still have to loop through the set to create and send the html doc, in which case you're going to want them coming out in "blocks". You probably don't need to do that looping, though, and if we can see your cursor we can probably eliminate that as well.Code:select * From Customers C Join Orders O on C.CustomerNumber = O.CustomerNumber Where Orders.DueQuantity > 0 Order By C.CustomerNumber




Reply With Quote
