简体   繁体   中英

SSRS multi-value parameter issue

I have a parameter that passes these values to a stored procedure:

"CA, FL, NY, NJ, MA, CT, RI".

The issue I'm having is that if I select the "ALL" option it does not bring back any "CT" values. It does bring back "CT" if I select it individually. I noticed that there are no records for "MA" so I don't know if this has something to do with it.

I'm parsing the values using a comma delimited splitter in SQL.

Also, does anyone know how to test the parameter in SQL Server to see how it's actually passing the values?

The stored procedure is as follows:

CREATE PROCEDURE plicense
(@division VARCHAR(500))
AS
SELECT a.lastname,
a.firstname,
b.divisionname
from Table A
INNER JOIN Table B
ON A.practid = B.practid
WHERE B.divisionname in (SELECT item from dbo.fnsplit(@division, ','))

The SSRS parameter is populated by a stored procedure that looks like this:

SELECT DISTINCT divisionid,
divisionname
FROM TABLE A
UNION
SELECT -1, 'N/A'    

The issue was in SSRS. I needed to add this to the parameter section of the main stored procedure: =join(Parameters!division.Value,",").

Create a function to separate the data as table

CREATE FUNCTION [dbo].[Split]
(
    @List NVARCHAR(2000),
    @SplitOn NVARCHAR(5)
)  
RETURNS @RtnValue TABLE 
(

    Id INT IDENTITY(1,1),
    Value NVARCHAR(100)
) 
AS  
BEGIN

WHILE (CHARINDEX(@SplitOn,@List)>0)
BEGIN 

INSERT INTO @RtnValue (value)
SELECT
    Value = LTRIM(RTRIM(SUBSTRING(@List,1,CHARINDEX(@SplitOn,@List)-1))) 


        SET @List = SUBSTRING(@List,CHARINDEX(@SplitOn,@List)+LEN(@SplitOn),LEN(@List))
END

    INSERT INTO @RtnValue (Value)
    SELECT Value = LTRIM(RTRIM(@List))

    RETURN
END

In your report,

Where column in (select dbo.split (@param))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM