带有包含多个计数语句的存储过程的 SSRS
SSRS with Stored Procedure containing multiple count statements
我有几行查询有多个计数语句。我已经为 select 计数语句创建了存储过程,当我在 SSMS 上使用 运行 它时它给出了结果,但是当我在 SSRS 中使用存储过程时它只给出了第一个查询输出。如何在使用 ssrs 时也获得其他查询输出?
来自评论的代码:
select count(*) as Field1
from #TempTable1;
select count(*) as Field2
from #TempTable2;
select count(distinct ANo) as F3
from #TempTable1;
select count(distinct BNo) as F4
from #TempTable2;
select count(*) as F5
from Table1
where InsertDate >= StartDate
and InsertDate <= EndDate
and value1 >= 2
and TestField = 0;
select count(*) as F6
from Table1
where InsertDate >= StartDate
and InsertDate <= EndDate
and value1 >= 2
and TestField = 1;
select count(*) as F7
from Table1
where InsertDate >= StartDate
and InsertDate <= EndDate
and value1 >= 2
and TestField = 0;
终于找到答案了
这是我所做的
声明局部变量并在查询中如下使用它们
select @A= count() 来自 Table1
Select @B= count() 来自 Table 2
Select @A 作为 Field1,@B 作为 Field2
这给出了单行输出。
我有几行查询有多个计数语句。我已经为 select 计数语句创建了存储过程,当我在 SSMS 上使用 运行 它时它给出了结果,但是当我在 SSRS 中使用存储过程时它只给出了第一个查询输出。如何在使用 ssrs 时也获得其他查询输出?
来自评论的代码:
select count(*) as Field1
from #TempTable1;
select count(*) as Field2
from #TempTable2;
select count(distinct ANo) as F3
from #TempTable1;
select count(distinct BNo) as F4
from #TempTable2;
select count(*) as F5
from Table1
where InsertDate >= StartDate
and InsertDate <= EndDate
and value1 >= 2
and TestField = 0;
select count(*) as F6
from Table1
where InsertDate >= StartDate
and InsertDate <= EndDate
and value1 >= 2
and TestField = 1;
select count(*) as F7
from Table1
where InsertDate >= StartDate
and InsertDate <= EndDate
and value1 >= 2
and TestField = 0;
终于找到答案了
这是我所做的 声明局部变量并在查询中如下使用它们
select @A= count() 来自 Table1 Select @B= count() 来自 Table 2
Select @A 作为 Field1,@B 作为 Field2
这给出了单行输出。