0
我正在處理SSRS中的一個報告,該報告具有可以具有多個值的參數。我可以傳遞一個參數值到查詢就好了。我在多個值的查詢中使用IN @Paramter,並且我也使參數接受多個值。但是,當我想要所有的值時,查詢不起作用。如何在查詢SSRS報告中使用多值參數?
我正在處理SSRS中的一個報告,該報告具有可以具有多個值的參數。我可以傳遞一個參數值到查詢就好了。我在多個值的查詢中使用IN @Paramter,並且我也使參數接受多個值。但是,當我想要所有的值時,查詢不起作用。如何在查詢SSRS報告中使用多值參數?
在SO上有幾個關於將多值參數傳遞給SSRS中的數據集查詢的答案。看到這個 - >Passing multiple values for a single parameter in Reporting Services。
我無法重現您描述的場景(選擇一個值有效,但所有值都不起作用)。但是,我使用SQL Server 2008作爲數據源實現了上述鏈接(Minks)中的答案之一。以下是詳細內容:
我有一個名爲@ ReportParameter1(Value字段= ID,標籤字段=描述)的參數是從以下數據集查詢填充:
select 1 as id, 'choice1' as description union
select 2 as id, 'choice2' as description union
select 3 as id, 'choice3' as description union
select 4 as id, 'choice4' as description
然後,我有我的報告數據集查詢如:
select * from
(select 1 as id union
select 2 as id union
select 3 as id union
select 4 as id) x
where id in (@ReportParameter1)
下的報表數據集參數選項卡,我有以下表達式@ ReportParameter1設置:
=Split(Join([email protected],","),",")
如果我選擇了@ ReportParameter1 ALL值,則查詢有效地變成:
select * from
(select 1 as id union
select 2 as id union
select 3 as id union
select 4 as id) x
where id in (1,2,3,4)
你是什麼意思的「查詢不工作」呢?你有任何種類或錯誤?當您選擇多個值而不是全部值時,查詢是否工作? – JodyT
當我嘗試傳遞多個值時,報告不會返回任何數據。我不知道如何設置報告中的參數以及如何正確分配值。 – tsqln00b
您沒有與參數相關的值的數據集嗎? – ShellNinja