title: How to do loop in stored procedure for each row return by select statement
body: <p>I have a 1 stored procedure in which i have used following query:</p>
  
  <pre><code>DECLARE @product_id int
  select @product_id=id from rpidata where collection_id = 354
  select @product_id
  </code></pre>
  
  <p>And it gives me only 1 last record.
  Now when i hit below query then it gives me 5 records.</p>
  
  <pre><code> select id,ngj_id,tul_price from rpidata where collection_id = 354
  </code></pre>
  
  <p>Now i want to get all these records and do loop to calculate other prices.
  Example:</p>
  
  <pre><code> DECLARE @product_id int
      for loop start //To traverse all 5 records
         select @product_id=id from rpidata where collection_id = 354
         select @product_id
         //My custom calculation for other fields.
     for loop end
  </code></pre>
  
  <p>How can i do that ?</p>