将多个参数从存储过程传递到水晶报告

时间:2016-01-06 21:45:32

标签: sql sql-server sql-server-2008 crystal-reports

我编写了以下存储过程来返回两个参数(字段),每当在Management Studio中执行时,都会显示两个select语句的结果。但是,当通过Crystakl Reports连接时,只显示第一个参数(即计数)。

USE [database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

BEGIN
    SET NOCOUNT ON;
    SELECT count(ID)as Counted from tab where Stat='1' 
    SELECT count(ID)as Counted2 from tab where Stat='2'
END

1 个答案:

答案 0 :(得分:0)

更改SELECT查询以包含两个输出

SELECT sum(case when Stat='1' then 1 else 0 end) as Counted, 
       sum(case when Stat='2' then 1 else 0 end) as Counted2 
from dbo.Batch