SSRS Passing multi valued parameter to select statement

In the Query Designer, when I execute this, it works beautifully.  I put in multiple values and get results.  When I try to preview the report I get an error message that the query execution failed for the dataset.  Incorrect syntax near ','.   When running the report the multi value parameter @MatterID_ would be something like 10001.001,10001.002.  Is the problem at the place where I'm setting @MatterIDs_?

DECLARE @MatterIDs_ varchar(2000), @Delimiter CHAR(1)
SET @Delimiter = ','
SET @MatterIDs_ = @Delimiter + @MatterID_ + @Delimiter

Select vw_LP_ClientMatterLedgerHistory.MatterId
      , vw_LP_ClientMatterLedgerHistory.ClientId
      , vw_LP_ClientMatterLedgerHistory.ShortDesc
      , vw_LP_ClientMatterLedgerHistory.ClientSort
      , vw_LP_ClientMatterLedgerHistory.StmnNo
      , vw_LP_ClientMatterLedgerHistory.QMASTERCLIENT
      , vw_LP_ClientMatterLedgerHistory.InvoiceAmount
      , vw_LP_ClientMatterLedgerHistory.InvoiceDate
      , vw_LP_ClientMatterLedgerHistory.InvoicePayment
      , vw_LP_ClientMatterLedgerHistory.PaymentDate
      , vw_LP_ClientMatterLedgerHistory.InvoiceWriteoff
      , vw_LP_ClientMatterLedgerHistory.InvoiceUnapplied
From Prolaw.dbo.vw_LP_ClientMatterLedgerHistory as vw_LP_ClientMatterLedgerHistory

JOIN             (
            SELECT DISTINCT ParamValue = LTRIM(SUBSTRING(@MatterIDs_,N+1,CHARINDEX(@Delimiter,@MatterIDs_,N+1)-N-1))
            FROM dbo.DC_Tally
            WHERE N < LEN(@MatterIDs_)
                        AND SUBSTRING(@MatterIDs_,N,1) = @Delimiter
        ) Sub
       ON vw_LP_ClientMatterLedgerHistory.MatterId LIKE Sub.ParamValue + '%'
       or vw_LP_ClientMatterLedgerHistory.QMASTERCLIENT LIKE  Sub.ParamValue + '%'

(((vw_LP_ClientMatterLedgerHistory.InvoiceDate >= @StartDate)
And (vw_LP_ClientMatterLedgerHistory.InvoiceDate <= @EndDate))
Or vw_LP_ClientMatterLedgerHistory.StmnNo = 99999999)
Order by vw_LP_ClientMatterLedgerHistory.ClientId
      , vw_LP_ClientMatterLedgerHistory.MatterId
      , vw_LP_ClientMatterLedgerHistory.StmnNo desc
      , vw_LP_ClientMatterLedgerHistory.InvoiceAmount desc
      --, vw_LP_ClientMatterLedgerHistory.StmnNo
      , vw_LP_ClientMatterLedgerHistory.InvoiceDate
      --, vw_LP_ClientMatterLedgerHistory.InvoiceAmount
      , vw_LP_ClientMatterLedgerHistory.PaymentDate
      , vw_LP_ClientMatterLedgerHistory.InvoicePayment
      , vw_LP_ClientMatterLedgerHistory.InvoiceWriteoff
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.

Vikas GargAssociate Principal EngineerCommented:

the above query seems ok while working with SQL because @MatterIDs_ parameter accepts single value.

If you wish to use multivalue parameter in SSRS you have to use that parameter as returning multi values

For ex. select * from table where id in (@MatterIDs_)

The below is very good link showing how to use multi value parameter in SSRS

SSRS Multi Value Parameter

Hope this would help

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
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

From novice to tech pro — start learning today.