title: Execute SQL Server stored procedures sequentially
body: <p>I've some case about executing stored procedures in SQL Server.</p>
  
  <p>Maybe it's unusual practice, but I've stored a list of stored procedure names in a table. The table is about like this (let's call it <code>TableFoo</code>):</p>
  
  <pre><code>| SPId |  SPName  |
  -------------------
  |  1   | spr_name1|
  |  2   | spr_name2|
  |  3   | spr_name3|
  |  4   | spr_name4|
  ...
  </code></pre>
  
  <p>I want to call/execute a list of stored procedure that generated from the query result on <code>TableFoo</code>, the query is about like this:</p>
  
  <pre><code>SELECT SPName 
  FROM TableFoo 
  WHERE SPId IN (1, 2, 3)
  </code></pre>
  
  <p>I want to execute the stored procedures sequentially per row</p>
  
  <p>I mean I want to do this :)</p>
  
  <pre><code>SELECT EXEC(SpName)
  FROM TableFoo
  WHERE SPId IN (1, 2, 3)
  </code></pre>
  
  <p>but that does not work</p>
  
  <p>It's any solution beside using a <code>CURSOR</code> ?</p>
  
  <p>Thanks in advance.</p>