title: SQL Server stored procedure generates results but doesn't return them
body: <p>I have this stored procedure:</p>
  
  <pre><code>alter PROCEDURE [dbo].[DynamicDropDownList]
  (
      @TableName varchar(100),
      @DataTextField varchar(100),
      @ValueTextField varchar(100)
  )
  AS
  BEGIN
  SET NOCOUNT ON; 
  
  declare @results table (DataTextField varchar(255), DataValueFIeld varchar(2));
      declare @sql varchar(max);
  
      set @sql = ('select ' + @DataTextField + ', ' + @ValueTextField +
                  ' from ' + @TableName +
                  ' order by ' + @DataTextField);
  
      exec(@sql);
  
      return;
  END
  </code></pre>
  
  <p>When I run it in LinqPad, I get this output:</p>
  
  <p><img src="https://i.stack.imgur.com/EjrFm.png" alt="output"></p>
  
  <p>Code that is returning "results 0":</p>
  
  <pre><code>var results = db.DynamicDropDownList("Countries", "Country", "CountryCode");
  </code></pre>
  
  <p>In my web project, I'm never able to access the result set - it just says nothing was returned. What am I doing wrong that is preventing the result set from being returned?</p>