title: Iterate through rows in SQL Server 2008
body: <p>Consider the table SAMPLE:</p>
  
  <pre><code>id       integer
  name     nvarchar(10)
  </code></pre>
  
  <p>There is a stored proc called <code>myproc</code>. It takes only one paramater ( which is id)</p>
  
  <p>Given a name as parameter, find all rows with the <code>name = @nameparameter</code> and pass all those ids
  to <code>myproc</code></p>
  
  <p>eg:</p>
  
  <pre><code>sample-&gt;
  1   mark
  2   mark
  3   stu
  41  mark
  </code></pre>
  
  <p>When <code>mark</code> is passed, <code>1 ,2 and 41</code> are to be passed to <code>myproc</code> individually.</p>
  
  <p>i.e. the following should happen:</p>
  
  <pre><code>execute myproc 1
  execute myproc 2
  execute myproc 41
  </code></pre>
  
  <p>I can't touch <code>myproc</code> nor see its content. I just have to pass the values to it.</p>