我有一个计算时差的函数,不包括周末,我已经创建了一个存储过程来调用该函数。当我测试sp时,只显示了消息部分,我是新的,不确定这是否正确。我无法将参数传递给SSRS。请多多帮助,谢谢。
Alter Proc Test_1
@DownTime datetime,
@Uptime datetime =null --since there are some null value in uptime column
AS
Begin
print 'enter'
declare @duration int
select @duration = [dbo].[CalcWorkMinutes](@DownTime,@Uptime)
print 'abc'
;with cte_test2
as (
SELECT DownTime
,UpTime
,datediff(hh,DownTime,UpTime) AS duration
FROM Test
)
select DownTime,UpTime,duration from cte_test2
where DownTime = @DownTime and UpTime=@UpTime
and duration=@duration
--print 'pass'
print 'duration'+' '+convert(varchar,@duration)
RETURN
END
--execute [dbo].[test_1] @downtime ='2017-06-02 09:00:00.000', @Uptime ='2017-06-05 09:00:00.000'
答案 0 :(得分:1)
Alter Proc Test_1
@startdate datetime,
@enddate datetime --since there are some null value in uptime column
AS
Begin
print 'enter'
SELECT
DownTime
,UpTime
,[dbo].[CalcWorkMinutes](DownTime,UpTime) AS duration
FROM Test as a
where
downtime >= @startdate
and b.downtime < dateadd(day,1,@enddate)
RETURN
END