创建一个数据集,该数据集是SSRS中另一个数据集的子集(Create a dataset which is a subset of another dataset in SSRS)

编程入门 行业动态 更新时间:2024-10-22 08:30:11
创建一个数据集,该数据集是SSRS中另一个数据集的子集(Create a dataset which is a subset of another dataset in SSRS)

在我的SSRS报告中,我已经有了一个数据集A(通过运行SQL脚本),参数P1使用A中的所有记录。现在我想获得A的子集,并使用另一个参数P2来引用它。

是否有可能同时获取数据集的整体和子集,并且只运行一次脚本?

我想创建共享数据集是一种可行的方法,但数据集A仅供本地使用,不应共享。

In my SSRS report, I already have a dataset A(by running a SQL script), and parameter P1 use all the records in A. Now I want to get a subset of A, and use another parameter P2 to refer to it.

Is it possible that get the whole and the subset of the dataset at the sametime and only run the script once?

I guess creating a shared dataset is a possible way, but the dataset A is just for locally use and shouldn't be shared.

最满意答案

简短的回答

不,这是不可能的。

替代

您可以修改查询,以便返回一列以填充P1参数,并返回其他列以填充P2。 例:

select 'Foo' P1, 'Foo' P2 union all select 'Bar', 'Bar' union all select 'Foobar', null

返回:

P1 P2 Foo Foo Bar Bar Foobar null

使用P1列填充P1参数,使用P2填充P2参数。

注意子集列(在我的情况下为P2)的值小于P1,如果您的参数设置为允许NULL值,它将在选择列表中显示NULL选项,否则不会。

这个解决方案可能对您有用,但如果您需要数据集只运行一次我不确定,我认为SSRS将为每个参数运行查询,即使两个参数都是从一个数据集填充的。

如果这有帮助,请告诉我。

Short answer

No, it is not possible.

Alternative

You can modify your query in order to it returns one column for populate the P1 parameter and other column to populate P2. Example:

select 'Foo' P1, 'Foo' P2 union all select 'Bar', 'Bar' union all select 'Foobar', null

Returns:

P1 P2 Foo Foo Bar Bar Foobar null

Use P1 column for populate the P1 parameter and P2 for populate P2 parameter.

Note the subset column (P2 in my case) has less values than P1, if your parameter is set to allow NULL values, it will show the NULL option in select list otherwise it won't.

This solution could work for you but if you need the dataset runs only once I am unsure of that, I think SSRS will run the query for every parameter even if both parameters are being populated from one dataset.

Let me know if this helps.

更多推荐

本文发布于:2023-04-29 12:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336371.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   子集   创建一个   dataset   subset

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!