当前位置: 代码迷 >> Sql Server >> 大家帮小弟我看看这个存储过程错哪了呢?该如何修改呢
  详细解决方案

大家帮小弟我看看这个存储过程错哪了呢?该如何修改呢

热度:13   发布时间:2016-04-27 16:28:17.0
大家帮我看看这个存储过程哪里错了呢?该怎么修改呢?
CREATE   proc   getInfo
@sip   varchar(50),   /*传入参数*/
@dip   varchar(50),   /*传入参数*/
@Zgjcs   int   output,
@Zbgjcs   int   output,
@Gjcs   int   output,
@Zfsbs   int   output,
@Zfssjl   int   output,
@Zjsbs   int   output,
@Zjssjl   int   output,
@Fsbs   int   output,
@Fssjl   int   output
as
begin
    @Zgjcs   =   select   (select   count(*)   from   Program1   where     [email protected]   )   +   (select   count(*)     from   Program2   where     [email protected]);
    @Zbgjcs   =   select   (select   count(*)     from   Program1   where     [email protected])   +   (select   count(*)     from   Program2   where     [email protected]);
    @Gjcs   =   select   (select   count(*)   from   Program1   where     [email protected]   and   [email protected])   +     (select   count(*)     from   Program2   where     [email protected]   and   [email protected]);
    select   @Zfsbs   =   (sum(a.trigger_times)+sum(b.repeat)),   @Zfssjl   =   sum(b.traffic)   from   Program1   a,   Program2   b   where   [email protected]   or   [email protected];
    select   @Zjsbs   =   (sum(a.trigger_times)+sum(b.repeat)),   @Zjssjl   =   sum(b.traffic)   from   Program1   a,   Program2   b   where   [email protected]   or   [email protected];
    select   @Fsbs   =     (sum(a.trigger_times)+sum(b.repeat)),     @Fssjl   =   sum(b.traffic)     from   Program1   a,   Program2   b   where   ([email protected]   and   [email protected])   or   ([email protected]   and   [email protected]);
end
GO

------解决方案--------------------
@Zgjcs = select (select count(*) from Program1 where [email protected] ) + (select count(*) from Program2 where [email protected]);

是不是应该是

select @Zgjcs=(select count(*) from Program1 where [email protected] ) + (select count(*) from Program2 where [email protected]);
------解决方案--------------------
CREATE proc getInfo
@sip varchar(50), /*传入参数*/
@dip varchar(50), /*传入参数*/
@Zgjcs int output,
@Zbgjcs int output,
@Gjcs int output,
@Zfsbs int output,
@Zfssjl int output,
@Zjsbs int output,
@Zjssjl int output,
@Fsbs int output,
@Fssjl int output
as
begin
set @Zgjcs = (select count(*) from Program1 where [email protected] ) + (select count(*) from Program2 where [email protected])
set @Zbgjcs = (select count(*) from Program1 where [email protected]) + (select count(*) from Program2 where [email protected])
set @Gjcs = (select count(*) from Program1 where [email protected] and [email protected]) + (select count(*) from Program2 where [email protected] and [email protected])
select @Zfsbs = (sum(a.trigger_times)+sum(b.repeat)), @Zfssjl = sum(b.traffic) from Program1 a, Program2 b where [email protected] or [email protected]
select @Zjsbs = (sum(a.trigger_times)+sum(b.repeat)), @Zjssjl = sum(b.traffic) from Program1 a, Program2 b where [email protected] or [email protected]
select @Fsbs = (sum(a.trigger_times)+sum(b.repeat)), @Fssjl = sum(b.traffic) from Program1 a, Program2 b where ([email protected] and [email protected]) or ([email protected] and [email protected])
end
GO
这样试试
  相关解决方案