日期:2014-05-19  浏览次数:20449 次

客户端无法执行存储过程?
我在数据库中建立了一个存储过程:/*此存储过程的作用是将月度的每日充值金额输出到临时表every_order
在程序中输出充值明细报表中使用此过程*/
CREATE   procedure   EveryOrderMoney
@StartDate   smalldatetime,
@EndDate   smalldatetime,
@nextdate   smalldatetime
as  
truncate   table   EVERYDAY_ORDER
while   @startdate <=@enddate
begin
set   @nextdate=@startdate+1
insert   into   EVERYDAY_ORDER
select   sum(order_money)   as   order_money,count(*),@startdate   from   order_meal   where   meal_date> =convert(char(10),@startdate,120)   and   meal_date <convert(char(10),@nextdate,120)
  set   @startdate=@nextdate
end
GO

在程序中会传递这几个参数,在我电脑中执行没问题(我电脑上已安装了SQl管理工具),但将程序分发给其它客户端后,运行程序后好像没有执行此过程,不知还有哪些地方要设置?我已在数据库中给了此用户的执行存储过程的权限


------解决方案--------------------
存储过程这样改
CREATE procedure EveryOrderMoney
@StartDate smalldatetime,
@EndDate smalldatetime,
@nextdate smalldatetime
as
set nocount on 必须加上
truncate table EVERYDAY_ORDER
while @startdate <=@enddate
begin
set @nextdate=@startdate+1
insert into EVERYDAY_ORDER
select sum(order_money) as order_money,count(*),@startdate from order_meal where meal_date> =convert(char(10),@startdate,120) and meal_date <convert(char(10),@nextdate,120)
set @startdate=@nextdate
end
set nocount on--必须加上
GO