注册 登录
编程论坛 SQL Server论坛

[求助]SQL的存储过程改为视图

lxbcool222 发布于 2008-06-21 13:06, 894 次点击
请高手帮我把下面的存储过程改为视图..谢谢..

create procedure spRoomSale
@StartDate smalldatetime,
@EndDate smalldatetime
as
select rtype,rname,
(select sum(cCost) from tblClient
left join tblRoom on tblClient.rnum=tblRoom.rnum
where (tblClient.cInTime between @StartDate and @EndDate)
and (tblRoomType.rtype=tblRoom.rtype)
)as sale,
(select count(tblClient.cId)from tblClient
left join tblRoom on tblClient.rnum=tblRoom.rnum
where (tblClient.cInTime between @StartDate and @EndDate)
and (tblRoomType.rtype=tblRoom.rtype)
)as salenum
from tblRoomType

GO
3 回复
#2
makebest2008-06-21 13:14
视图和存储过程不是等价的,@StartDate 和 @EndDate 在视图中无法使用
#3
lxbcool2222008-06-21 13:18
我知道这两个变量在视图里面没办法实现,但可以用别的代替的不是吗?
@StartDate是起始日期,@EndDate是终止日期.
#4
冰彩虹2008-06-22 08:03
视图是不能传参数的吧
1