title: Select to retrieve multiple rows then loop results for Insert statement
body: <p>I need to create a stored procedure to do the following;</p>
  
  <pre><code>    SELECT * FROM TABLE1
  </code></pre>
  
  <p>Then for each row returned;</p>
  
  <pre><code>    INSERT INTO TABLE2 (column1, column2, column3,...) 
      VALUES (value1, value2, value3,...)
  </code></pre>
  
  <p>How would I go about doing this?</p>
  
  <p><em><strong></em></strong> UPDATE <strong>**</strong></p>
  
  <p>So based on responses so far I've got the following sql;</p>
  
  <pre><code>INSERT INTO recEntrantStatus (entrantId, roundId, judgeId)
  SELECT entrantId, judgeId
  FROM recEntrantStatus
  WHERE roundId = 0
  AND voted = true
  AND enterNextround = true
  </code></pre>
  
  <p>But I need to add a fixed value eg an input @round into the newly created records in the column roundId.</p>
  
  <p>How do I go about doing that?</p>
  
  <p>Thanks.</p>
  
  <p>------------------------------------- UPDATE 2 -------------------------------------------</p>
  
  <p>So thanks to some significant help from you guys, I've now got the following SQL which works great at this stage:</p>
  
  <pre><code>  INSERT INTO recEntrantStatus (entrantId, roundId, judgeId, notified, voted, enterNextRound)
    SELECT entrantId, (@round + 1), judgeId, 0, 0, 0
    FROM recEntrantStatus
    WHERE roundId = @round
    AND voted = 1
    AND enterNextround = 1
  </code></pre>
  
  <p>This code checks for all records where 'enterNextRound' is true, and then creates a new record for each of them.</p>
  
  <p>However, I now need to expand this so that:</p>
  
  <p>A) Check a second table(tblJudges) for all judges and get an array of all the judges Id's (Id)</p>
  
  <p>B) Do the same as in the above example except now creating each of the above records for each of the judges / judges Id's obtained from step A. </p>
  
  <p>Any help / suggestions would as always be greatly appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>CLOSED - Question posted as a new question due to additional requirements. Thanks!</p>