简体   繁体   English

SSRS 如何在订阅中查看多值参数

[英]SSRS How to see multi value parameter in subscription

I tried to get value from query or to specify values, as soon as the parameter is multi value i can't see the data when i'm trying to make my subscription.我试图从查询中获取值或指定值,只要参数是多值,我在尝试订阅时就看不到数据。
my request looks like:我的请求看起来像:

select id from employee where canal in(@canal)

在此处输入图像描述

what should i do, i'm totally stuck,我该怎么办,我完全卡住了,
when i did research i saw data driven subscription but i don't have access to it apparently, don't know if that help当我进行研究时,我看到了数据驱动的订阅,但我显然无法访问它,不知道这是否有帮助

I'll start by saying sorry this isn't a pleasant answer.我首先要说对不起,这不是一个令人愉快的答案。 You've run into a limitation with the built-in functionality.您遇到了内置功能的限制。 Thankfully there are workarounds.值得庆幸的是,有解决方法。

The problem is that you can only pass 1 value into the data-driven subscription.问题是您只能将 1 个值传递给数据驱动订阅。 So you have use a comma-separated list and get the query/report to parse out the values.因此,您使用了逗号分隔的列表并获取查询/报告以解析出值。

  1. If you have or can create a Split function in your database, that is a good option.如果您有或可以在数据库中创建Split function,这是一个不错的选择。 This would be a table-valued user defined function and there are some easy to find examples already.这将是用户定义的表值 function 并且已经有一些容易找到的示例。 Also this function is generally good to have for other use cases anyway.无论如何,这个 function 通常也适用于其他用例。 With this your SQL would read:有了这个,您的 SQL 将显示:

    where canal in Split(@canal)斯普利特的运河在哪里(@canal)

  2. SSRS works really well with SQL Server, but when you use an ODBC connection, the parameter support is limited. SSRS 与 SQL 服务器配合得非常好,但是当您使用 ODBC 连接时,参数支持是有限的。 You can use the same multi-value parameter workaround that is required in those cases.您可以使用在这些情况下所需的相同多值参数解决方法。

    • In the Dataset properties > parameters tab, use an expression like this to combine the values into a single comma-separated string surrounded by commas.在“数据集属性”>“参数”选项卡中,使用这样的表达式将值组合成一个由逗号包围的逗号分隔字符串。

    ="," + Join(Parameters.canal,Value, ",") + "," ="," + Join(Parameters.canal,Value, ",") + ","

    • The SQL would look like this: SQL 看起来像这样:

    where @ like '%,' + canal + ',%'其中@like '%,' + canal + ',%'

Basically, this searches row-by-row for values that are contained in the string.基本上,这会逐行搜索字符串中包含的值。

In either case, the query in your data-driven subscription settings will need to return the comma-separated string.无论哪种情况,数据驱动订阅设置中的查询都需要返回逗号分隔的字符串。 Then you can select that column in the report parameters value field.然后您可以在报告参数值字段中的 select 该列。 Hope this helps!希望这可以帮助!

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

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