编程论坛's Archiver

lxbcool222 发表于 2008-6-21 13:06

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

请高手帮我把下面的存储过程改为视图..谢谢..

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

makebest 发表于 2008-6-21 13:14

视图和存储过程不是等价的,@StartDate 和 @EndDate 在视图中无法使用

lxbcool222 发表于 2008-6-21 13:18

我知道这两个变量在视图里面没办法实现,但可以用别的代替的不是吗?
@StartDate是起始日期,@EndDate是终止日期.

冰彩虹 发表于 2008-6-22 08:03

视图是不能传参数的吧

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.