Multi value parameter SSRS 2008

I am having troubles while trying to get a multi-value parameter query to work from SSRS 2008. After much perusing of the web and EE, nothing quite seems to work.

I have built a test SSRS report which should return 3 records. If I type the "in" statement directly in SQL SP it works fine. When I use the SSRS multi-value parameter I get only the first of three records returned.

First, in the SSRS report's Dataset Parameters section I declare the following:
@pProject =join(Parameters!pProject.Value, ",")

When running the report, I get the first of three values back. I am using a function from Angellll to handle the parameter. I am calling the parameter in the SP by using this:

SELECT        project, project_desc
FROM            projectsinfo
WHERE        project in ( select rtrim(value) from dbo.parmsToList(@pProject,','))

If I change this code to use this where statement:
where project in ('01360006', '01490102', '01880052')

I get three records back as expected.

Any help is appreciated.
alter FUNCTION [dbo].[ParmsToList] (@Parameters varchar(max), @delimiter varchar(10) ) 
returns @result TABLE (Value varchar(max)) 
    declare @dx varchar(9) 
    -- declare @loops int 
     --set @loops = 0 
     DECLARE @TempList table 
          Value varchar(8000) 
     if @delimiter is null  set @delimiter = ' ' 
     if datalength(@delimiter) < 1 set @delimiter = ' ' 
     set @dx = left(@delimiter, datalength(@delimiter)-1) 
     DECLARE @Value varchar(8000), @Pos int 
     SET @Parameters = LTRIM(@Parameters)+ @delimiter 
     SET @Pos = CHARINDEX(@delimiter, @Parameters, 1) 
     IF REPLACE(@Parameters, @delimiter, @dx) <> '' 
          WHILE @Pos > 0 -- AND @Loops < 100 
               --set @loops = @loops + 1 
               SET @Value = LEFT(@Parameters, @Pos - 1) 
               IF @Value <> '' 
                    INSERT INTO @TempList (Value) VALUES (@Value) --Use Appropriate conversion 
               SET @Parameters = SUBSTRING(@Parameters, @Pos+ datalength(@delimiter), 8000) 
               SET @Pos = CHARINDEX(@delimiter, @Parameters, 1) 
     INSERT @result 
     SELECT value 
        FROM @TempList 

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I trust that you've checked  thye function will return 3 records when
SET @pProject = '01360006, 01490102, 01880052' is used in:
select rtrim(value) from dbo.parmsToList(@pProject,',')

How about the the value of the parameter that is generated from the report
@pProject =join(Parameters!pProject.Value, ",")
are they equal to '01360006, 01490102, 01880052'  or similar format ?
mirthlessAuthor Commented:
when I run:
select rtrim(value) from dbo.parmsToList('01360006, 01490102, 01880052',',')
I get three values returned in a table-like format.

When I run profiler at the report using the parameter value of:
=join(Parameters!pProject.Value, ",")
I get @pProject=N'01360006 ,01490102 ,01880052 '
I see nothing wrong on the function or even when running the nvarchar values againts the function. Have you tried just running the SQL statement returned from the profiler if you get the 3 records back.  Can you post the proc or the SQL that you are using in the report, I want to see how the @pProject was declared.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mirthlessAuthor Commented:
You got it man, I had the parameter too short, it was varchar(16)!  After I set it longer all works as expected.
Glad to help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB Reporting Tools

From novice to tech pro — start learning today.