title: Stored procedure return into DataSet in C# .Net
body: <p>I want to return virtual table from stored procedure and I want to use it in dataset in c# .net. My procedure is a little complex and can't find how to return a table and set it in a dataset </p>
  
  <p>Here is my procedure to modify:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[Procedure1] 
  
      @Start datetime, 
      @Finish datetime,
      @TimeRange time
  AS
  BEGIN
  
      SET NOCOUNT ON;
  
      declare @TimeRanges as TABLE (SessionStart datetime, SessionEnd datetime);
  
       with TimeRanges as (
    select @Start as StartTime, @Start + @TimeRange as EndTime
    union all
    select StartTime + @TimeRange, EndTime + @TimeRange
      from TimeRanges
      where StartTime &lt; @Finish )
    select StartTime, EndTime, Count( Test.ScenarioID ) as TotalPeaks
      from TimeRanges as TR left outer join
        dbo.Test as Test on TR.StartTime &lt;= Test.SessionStartTime and Test.SessionCloseTime &lt; TR.EndTime
      group by TR.StartTime, TR.EndTime   
  END
  </code></pre>