大家帮我看看这个存储过程哪里错了呢?该怎么修改呢?
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 sip=@sip ) + (select count(*) from Program2 where sip=@sip);
@Zbgjcs = select (select count(*) from Program1 where dip=@dip) + (select count(*) from Program2 where dip=@dip);
@Gjcs = select (select count(*) from Program1 where sip=@sip and dip=@dip) + (select count(*) from Program2 where sip=@sip and dip=@dip);
select @Zfsbs = (sum(a.trigger_times)+sum(b.repeat)), @Zfssjl = sum(b.traffic) from Program1 a, Program2 b where a.sip=@sip or b.sip=@sip;
select @Zjsbs = (sum(a.trigger_times)+sum(b.repeat)), @Zjssjl = sum(b.traffic) from Program1 a, Program2 b where a.dip=@dip or b.dip=@dip;
select @Fsbs = (sum(a.trigger_times)+sum(b.repeat)), @Fssjl = sum(b.traffic) from Program1 a, Program2 b where (a.sip=@sip and a.dip=@dip) or (b.sip=@sip and b.dip=@dip);
end
GO
------解决方案--------------------@Zgjcs = select (select count(*) from Program1 where sip=@sip ) + (select count(*) from Program2 where sip=@sip);
是不是应该是
select @Zgjcs=(select count(*) from Program1 where sip=@sip ) + (select count(*) from Program2 where sip=@sip);
------解决方案--------------------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 sip=@sip ) + (select count(*) from Program2 where sip=@sip)
set @Zbgjcs = (select count(*) from Program1 where dip=@dip) + (select count(*) from Program2 where dip=@dip)
set @Gjcs = (select count(*) from Program1 where sip=@sip and dip=@dip) + (select count(*) from Program2 where sip=@sip and dip=@dip)
select @Zfsbs = (sum(a.trigger_times)+sum(b.repeat)), @Zfssjl = sum(b.traffic) from Program1 a, Program2 b where a.sip=@sip or b.sip=@sip
select @Zjsbs = (sum(a.trigger_times)+sum(b.repeat)), @Zjssjl = sum(b.traffic) from Program1 a, Program2 b where a.dip=@dip or b.dip=@dip
select @Fsbs = (sum(a.trigger_times)+sum(b.repeat)), @Fssjl = sum(b.traffic) from Program1 a, Program2 b where (a.sip=@sip and a.dip=@dip) or (b.sip=@sip and b.dip=@dip)
end
GO
这样试试