You are absolutely right :)  Sorry, I am used to having to do it that way because there where different test phases with the same test numbers in it.  So I would have to loop through only the test numbers that are associated with that phase, I could not just do all of them.  Thanks for pointing that out! Here is the new one.

CREATE PROCEDURE getDpCount AS

/* declare local variables used for fetch */
declare @strPlanTestNo varchar(50)
declare @dpCount int

/* declare the cursor to get the count of datapoints for each test number */
declare dpcount cursor for
   Select count(intDatapointID) as dpcount, strTestNo from tblDatapoints where strTestNo = @strPlanTestNo
  Group by strTestNo

open dpcount
FETCH NEXT FROM  dpcount
          into @dpCount,  @strPlanTestNo

while (@@FETCH_STATUS = 0)
begin
  
  Update tblPlan set intPlanDpCount= @dpCount
  WHERE strPlanTestNo =  @strPlanTestNo
  
  FETCH NEXT FROM  dpcount
           into @dpCount
end
CLOSE dpcount
DEALLOCATE dpcount   
   
Select intPlanDpCount from tblPlan
GO
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to