SSRS multi-value parameter using a stored procedure

后端 未结 5 1764
长情又很酷
长情又很酷 2020-11-27 05:51

I am working on a SSRS report that uses a stored procedure containing a few parameters. I am having problems with two of the parameters because I want to have the option of

5条回答
  •  天命终不由人
    2020-11-27 06:28

    You need three things:

    1. In the SSRS dataset properties, pass the multi-value param to the stored procedure as a comma-delimited string

      =Join(Parameters!TerritoryMulti.Value, ",")
      
    2. In Sql Server, you need a table-value function that can split a comma-delimited string back out into a mini table (eg see here). edit: Since SQL Server 2016 you can use the built-in function STRING_SPLIT for this

    3. In the stored procedure, have a where clause something like this:

      WHERE sometable.TerritoryID in (select Item from dbo.ufnSplit(@TerritoryMulti,','))
      

      ... where ufnSplit is your splitting function from step 2.

    (Full steps and code in my blog post 'SSRS multi-value parameters with less fail'):

提交回复
热议问题