title: Loop through a recordset and use the result to do another SQL select and return the results
body: <p>I am completely new to stored procedure. This time, I need to create a stored procedure in MS SQL.</p>
  
  <p>Let's say I have the following table.</p>
  
  <pre><code>     Table name: ListOfProducts  
        --------------------------
         SomeID, ProductID  
  
           34, 4
           35, 8
           35, 11
  </code></pre>
  
  <p>How do I pass in a SomeID. Use this SomeID to select a recordset from table, ListOfProducts. Then loop through this record set.</p>
  
  <p>Let's say I pass in SomeID = 35.</p>
  
  <p>So, the record set will return 2 records with SomeID 35. In the loop, I will get ProductID 8 and 11, which will be used to do another select from another table.</p>
  
  <p>The stored procedure should return the results from the 2nd select.</p>
  
  <p>How can I do this in MS SQL stored procedure?</p>
  
  <p>Sorry, for this newbie question. Thanks for any help.</p>