我想從存儲過程返回虛擬表,我想在c#.net的數據集中使用它。我的過程是一個有點複雜,無法找到如何返回一個表,並設置它在數據集中存儲過程返回到DataSet中的C#.Net
這裏是我的程序修改:
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 < @Finish)
select StartTime, EndTime, Count(Test.ScenarioID) as TotalPeaks
from TimeRanges as TR left outer join
dbo.Test as Test on TR.StartTime <= Test.SessionStartTime and Test.SessionCloseTime < TR.EndTime
group by TR.StartTime, TR.EndTime
END
歡迎StackOverflow的樣本:如果您發佈的代碼,XML或數據樣本,** **請在高亮文本編輯器中的那些行並點擊編輯器工具欄上的「代碼示例」按鈕(「{}」),以精確地格式化和語法突出顯示它! –