Passing values for multi-value parameter in SSRS query string

后端 未结 3 1586
闹比i
闹比i 2021-02-09 23:17

I have two reports built using SSRS 2005. The first report is set to navigate to the second when a specific field is clicked. I am using an expression similar to the following

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-09 23:20

    Use join(Parameters!.Value,"&=") in the url for multivalued parameters.

    If you are passing these parameters into a dataset you need to do a join(Parameters!.Value) when you pass the parameter in and then use a split function in SQL. This one works well:

    ALTER FUNCTION [dbo].[fnSplitParam]
       (@RepParam nvarchar(4000), @Delim char(1)= ',')
    RETURNS @Values TABLE (Param nvarchar(4000))AS
      BEGIN
      DECLARE @chrind INT
      DECLARE @Piece nvarchar(100)
      SELECT @chrind = 1 
      WHILE @chrind > 0
        BEGIN
          SELECT @chrind = CHARINDEX(@Delim,@RepParam)
          IF @chrind  > 0
            SELECT @Piece = LEFT(@RepParam,@chrind - 1)
          ELSE
            SELECT @Piece = @RepParam
          INSERT  @Values(Param) VALUES(CAST(@Piece AS VARCHAR))
          SELECT @RepParam = RIGHT(@RepParam,LEN(@RepParam) - @chrind)
          IF LEN(@RepParam) = 0 BREAK
        END
      RETURN
      END
    

    I recommend using the single valued method if the end user does not have to select the parameters directly since it saves you 2 characters per parameter in the url.

提交回复
热议问题