| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦   
共有 327 人关注过本帖
标题:[求助]SQL的存储过程改为视图
收藏  订阅  推荐  打印
lxbcool222
Rank: 1
等级:新手上路
帖子:2
积分:122
注册:2007-11-26
[求助]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
2008-6-21 13:06
makebest
Rank: 3Rank: 3
等级:中级会员
帖子:379
积分:4056
注册:2005-3-17

视图和存储过程不是等价的,@StartDate 和 @EndDate 在视图中无法使用
2008-6-21 13:14
lxbcool222
Rank: 1
等级:新手上路
帖子:2
积分:122
注册:2007-11-26

我知道这两个变量在视图里面没办法实现,但可以用别的代替的不是吗?
@StartDate是起始日期,@EndDate是终止日期.
2008-6-21 13:18
冰彩虹
Rank: 12Rank: 12Rank: 12
等级:贵宾
帖子:716
积分:7370
威望:14
来自:上海
注册:2007-6-28

视图是不能传参数的吧

Flying without wings
2008-6-22 08:03
共有 326 人关注过本帖
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.048309 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved