hi guys,
im trying to loop through a table and call my function for each row. realise that this isn't the best use of sql functionality, but im still learning :D
the loop does work but calls the function, But, for each row it returns all the rows - before getting the next row id value :/
this is my code below
thanks
dan
declare @rowmin nchar(5)
select @rowmin = min(customerid)
from customers c
while exists
(select top 1 customerid
from customers c
where c.customerid > @rowmin)
begin
--proc here
select dbo.moretotalorders(@rowmin) as 'total orders', @rowmin
from customers
--increment row var
select top 1 @rowmin = min(customerid)
from customers c
where customerid > @rowmin
end