1
Answer

Looping through each record and modifying

Space Ghost

Space Ghost

14y
1.6k
1
Hi,

I am a bit stumped with this and cannot find the correct resources. What I want to do is loop through a result set in my stored procedure and change a specific field of each record. With I only want to do this if the record that is currently being check meets certain criteria. Below I will try to put it out more simple.

MyResultset has 10 records in.


WHILE MyResultSet HAS ROWS
BEGIN
   IF RMyResultset.Active = 'True'
      SET RMyResultset.Active = 'False'
   END IF

MyResultSet.MoveToNextRow
END

How can this be achieved to build this in my SQL Stored Procedure?

I hope this explains my scenario well enough.

Thanks,


Answers (1)