[英]How to make SSRS filter selection optional?
I'm using SQL Server 2005 Reporting Services to create a new report. 我正在使用SQL Server 2005 Reporting Services创建新报告。
This report has 2 optional parameters that can be selected by users or users can leave them blank. 该报告具有2个可选参数,用户可以选择这些参数,或者用户可以将其留为空白。 Both are dropdown selection.
两者都是下拉选择。
The problem that I'm facing is, I had set both parameters to Allow Null Value, but not Allow Blank Value. 我面临的问题是,我已将两个参数都设置为“允许空值”,但未设置“允许空白值”。 When I click on View Report button without select any filter criteria, the report give me 0 records.
当我单击“查看报告”按钮而不选择任何过滤条件时,该报告给了我0条记录。 But if I selected a value for both dropdown selection, the reports give me result.
但是,如果我为两个下拉菜单都选择了一个值,则报告会给我结果。
@Package
is varchar(100)
and @Plant
is tinyiny
. @Package
是varchar(100)
而@Plant
是tinyiny
。
I write the WHERE
clause in this way. 我以这种方式编写
WHERE
子句。 please help and much appreciate. 请帮助,非常感谢。
WHERE (@Package ='' OR PACKAGE_TYPE LIKE '%' + @Package + '%') AND
(@Plant IS NULL OR PLANT_ID = @Plant )
So when no filter criteria are selected, both @Package
and @Plant
are NULL
? 因此,当未选择任何过滤条件时,
@Package
和@Plant
均为NULL
?
In your WHERE
clause above, you're only handling @Plant
NULL
values. 在上面的
WHERE
子句中,您仅处理@Plant
NULL
值。
You need to check for NULL
@Package
, too, something like: 您还需要检查
NULL
@Package
,例如:
WHERE (@Package IS NULL OR @Package ='' OR PACKAGE_TYPE LIKE '%' + @Package + '%') AND
(@Plant IS NULL OR PLANT_ID = @Plant )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.