2017-07-11 70 views
0

我在我的SSRS上有6 filters,其中1 is of Department。我必須選擇multiple departments並根據這些選擇生成報告。但我沒有得到如何做到這一點。處理SSRS中的多值參數

我創建了一個stored procedure,它在報告中被調用。

ALTER PROC [dbo].[usp_getLessonLearntDetails] 
@AssetID nvarchar(50), 
@DepartmentID nvarchar(50), 
@Category varchar(50), 
@AuditType varchar(50), 
@AuditStartYear nvarchar(50), 
@AuditEndYear nvarchar(50) 

AS 

BEGIN 

SELECT 
ROW_NUMBER() OVER(ORDER BY AssetName ASC) AS Sno, 
LLD.LessonComputedID, tbl_Asset.AssetName, AT.AuditType, SY.Year+' - '+EY.Year as 'Audit Period', 
DE.DepartmentName, CT.CategoryName, LLD.Learnings, 
CAST(CASE WHEN (LLD.RepeatedObservation = 1) THEN 'True' ELSE 'False' END AS varchar(10)) as RepeatedObservation, 
LLD.RepeatedObservationReference, Att.Attachment 
FROM   tbl_LessonLearntDetails LLD INNER JOIN 
      tbl_Category CT ON CT.CategoryID = LLD.Title INNER JOIN 
      tbl_Asset ON LLD.AssetID = tbl_Asset.AssetID INNER JOIN 
      tbl_Department DE ON LLD.DepartmentID = DE.DepartmentID INNER JOIN 
      tbl_AuditType AT ON LLD.AuditTypeID = AT.AuditTypeID INNER JOIN 
      tbl_Attachment Att ON LLD.LessonLearntID= Att.LeassonLearntID INNER JOIN 
      tbl_AuditYear SY on SY.Year = LLD.AuditStartYear INNER JOIN     
      tbl_AuditYear EY on EY.Year = LLD.AuditEndYear 

     where ((('0'[email protected] and (1=1)) or [email protected]) and 
       (('0'[email protected] and (1=1)) or LLD.DepartmentID IN (@DepartmentID)) and 
       (('0'[email protected] and (1=1)) or [email protected]) and 
       (('0'[email protected] and (1=1)) or [email protected]) and 
       (('0'[email protected] and (1=1)) or (LLD.AuditStartYear >= @AuditStartYear)) and 
       (('0'[email protected] and (1=1)) or (LLD.AuditEndYear <= @AuditEndYear)) 
      ); 

END; 
+0

您可以使用表值參數或通過逗號分隔列表並使用'LIKE'來檢查這個 – MWillemse

+0

@MWillemse SSRS不知道什麼表值參數是廣告不會傳遞任何東西到sp – sepupic

+0

@Aakash Srivastava您應該將您的多值參數作爲varchar(...)傳遞,並且SSRS將傳遞一個以逗號分隔的列表。那麼你應該使用分割功能 – sepupic

回答

0

使用拆分功能將在這裏工作。我做的。

在哪裏條件下,使用split函數。

(('0'[email protected] AND (1=1)) OR LLD.DepartmentID IN (SELECT * FROM fnSplit(@DepartmentID,','))) 

謝謝大家的回覆。因爲你們只有我才能夠受到分裂的想法。