简体   繁体   English

ssrs多个值参数

[英]ssrs multiple values parameter

I know this question has been asked several times before, but the answers I have found do not work for my code, so I am posting it here. 我知道之前已经多次询问过这个问题,但我找到的答案对我的代码不起作用,所以我在这里发帖。 My query is in SQL Server v17.0. 我的查询是在SQL Server v17.0中。 I have an SSRS report with a code parameter, but it only shows values when 1 code is selected. 我有一个带有代码参数的SSRS报告,但它只显示选择1个代码时的值。 Under parameter props, I checked the 'allow multiple values' option, but that did nothing. 在参数道具下,我选中了“允许多个值”选项,但这没有做任何事情。 Any suggestions? 有什么建议么?

create procedure [roo].[get_cc_serv]
( @upc_code varchar(max) = ''   )
as
select 
acct_num = ser.account_number,
status_change_date = crd.date_status_chg,
upc14 = isnull(crd.upc_14, '-')

from fact.fact_cc_serv ser
join dim.dim_cc_card crd on 
ser.dim_cc_cardholder_key = 
crd.dim_cc_cardholder_key

where ser.end_date = 99991231
and crd.upc_14 is not null
and crd.upc_14 not like 'Z%'
and crd.upc_14 in (@upc_code)

Creating the procedure for this forces the multi-select to be treated as a single value. 为此创建过程会强制将多选项视为单个值。

If you embed the SQL query in your report instead of using a proc, it should work: 如果您在报表中嵌入SQL查询而不是使用proc,它应该工作:

Put this into a dataset in the report: 将其放入报告中的数据集中:

select 
acct_num = ser.account_number,
status_change_date = crd.date_status_chg,
upc14 = isnull(crd.upc_14, '-')

from fact.fact_cc_serv ser
join dim.dim_cc_card crd on 
ser.dim_cc_cardholder_key = 
crd.dim_cc_cardholder_key

where ser.end_date = 99991231
and crd.upc_14 is not null
and crd.upc_14 not like 'Z%'
and crd.upc_14 in (@upc_code)

If you must have this in a SP, you'll need to get a little fancier to hand in the multi-value parameter and handle the splitting yourself: https://stackoverflow.com/a/9862901/400375 如果您必须在SP中使用此功能,则需要获得一位小型设备来交付多值参数并自行处理拆分: https//stackoverflow.com/a/9862901/400375

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM