I have a SQL Stored Procedure which is never ending because of some values which are cached. But that is just a guess after debugging the procedure.
while @poid is not NULL
BEGIN
Update Item set Sales = (Select Sales from V_ITEM_Hierarchy where POID=@poid) where ItemID=@poid
Select @poid = i.ItemID
from V_ITEM_Hierarchy t inner join Item i on (t.POID = i.POID)
where ( abs(coalesce(t.Sales,0)-coalesce(i.Sales,0)) > 0.0001
END
I update the value “Sales” in Table Item with the Sales value of a view called “V_ITEM_Hierarchy” and then look again for values which are different. When I debug through the procedure the select-statement always returns the same value even if the Sales values are not different anymore because they were updated.
I tried to insert the command “DBCC DROPCLEANBUFFERS” but the select-statement still returns old values.
If the second query does not return any rows the value of @poid will NOT be updated. What you need is