SSRS 参数不接受多个值

SSRS Parameter not accepting multiple values

我正在尝试创建一个接受多个报告值的参数。如果我只 select 一次收集操作,则该报告会运行一个程序并且有效,但是当我尝试 select 多次时,我得到:

An error has occurred during report processing.
Query execution failed for dataset 'proc_Incentives'
Error converting data type nvarchar to int

在我的程序中,我将@CO_ID int 声明为一个变量。

在WHERE子句中,我在(@CO_ID).

中设置了CO.CodeID

此外,CO.CodeID 在数据库中存储为 INT。

在我的 SSRS 报告中,我创建了一个名为 'prmCollectionOp' 的新数据集,我在其中编写了一个简单的查询:

Select CodeID, Description from IDViewCollectionOp Order by Description;

然后我创建了一个名为 'CO_ID' 的新参数并将数据类型设为 Integer 并检查了 "Allow Multiple Values"。

在可用值下,我选择了从查询中获取值,选择了 prmCollectionOp 并将 CodeID 放在值字段中,将 Description 放在标签字段中。

对于默认值,我还选择了从查询中获取值并选择了具有 CodeID 值字段的数据集 prmCollectionOp。

这一切都适用于所选的单个收集操作,但不适用于多个。

关于允许在参数中 select 编辑多个值的我可能遗漏的任何建议?

谢谢,

我知道这是一个棘手的问题:我将推荐几篇文章来解释如何做到这一点。

一个来自 Scott Murray and the other is from Jeff Moden(Scott 实际上指的是 Jeff 在他的文章中)。

对于存储过程,您可以执行以下操作

斯科特解释说:

First we are passing in the concatenated multi-value parameter as a single entity and we use a varchar parameter (which must be large enough to accept the maximum length of all the parameters which might be selected). Next using the splitter function, the values are parsed out and placed into a temporary table, #YEAR_LIST. Last, the year criteria is moved from being part of the where clause to being part of the joins.

还有其他方法,但这应该可以解决问题。

希望对您有所帮助!

只需使用带逗号分隔符的连接多值参数(Dataset->Paremeter->Expression)

在存储过程中,用定界符(,) 分割输入值。然后使用 cross apply

处理查询中的值