SSRS2005: Using Multi-value parameter in Dataset query
Hi,
I am using the multi-value parameter in query like this:
select account0.name as name, account0.accountnumber as accountnumber, account0.address1_city as address1_city, account0.address1_county as address1_county, account0.customertypecodename as customertypecodename, account0.customertypecode as customertypecode, account0.accountid as accountid from FilteredAccount as account0
where (customertypecodename in (Join(Parameters!CustomerTypeCodeName.Value)) or @CustomerTypeCodeName in ('<All>'))
Error:
Incorrect syntax near the keyword 'Join'. (Microsoft SQL Server, Error: 156)
Any ideas?
Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH) (skype: ali.net.pk)
June 16th, 2011 2:46am
I thought it was an easy question, though. :).Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH) (skype: ali.net.pk)
Free Windows Admin Tool Kit Click here and download it now
June 17th, 2011 2:36am
Hi Ali,
Check the Below Syntax.
Make Sure You Execute the Query Without the Parameters and Get the Required Fileds and later You Can use this as an Expression:
select account0.name as name, account0.accountnumber as accountnumber, account0.address1_city as address1_city, account0.address1_county as address1_county, account0.customertypecodename as customertypecodename, account0.customertypecode as customertypecode, account0.accountid as accountid from FilteredAccount as account0
where (customertypecodename in (Join(Parameters!CustomerTypeCodeName.Value,",")) or Parameters!CustomerTypeCodeName.Value in ('<All>'))
Rakesh M J
Dont forget to mark it as Answered if found useful
MCTS,MCITP,MCSS
http://mycubeandreports.blogspot.com/
June 17th, 2011 5:43am
Rakesh!
Thanks for replying.
I tried the query execution without where clause and it worked fine. Report shown. However, after adding where clause (as it is provided by you), it is still showing the same error.
Any other idea?Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH) (skype: ali.net.pk)
Free Windows Admin Tool Kit Click here and download it now
June 17th, 2011 7:35am
Hi Ali,
Instead use the Syntax.
select account0.name as name, account0.accountnumber as accountnumber, account0.address1_city as address1_city, account0.address1_county as address1_county, account0.customertypecodename as customertypecodename, account0.customertypecode as customertypecode, account0.accountid as accountid from FilteredAccount as account0
where (customertypecodename in (@CustomerTypeCodeName))
You Cannot use Your Parameter in your Where Clause but send it as aurgument to Where.
Make sure you have Declared this Parameter as MultiValue in Your Report Parameters Pane.
Rakesh M J
Dont forget to mark it as Answered if found useful
MCTS,MCITP,MCSS
http://mycubeandreports.blogspot.com/
June 17th, 2011 7:46am
Hi Ali,
Thanks for your question.
Rakesh’s opinion is logical and valuable, thank you very much Rakesh.
Based on your description and your T-SQL query, it seems that there are two conditionals for the judgment, if you want to add check
Select All in the @CustomerTypeCodeName to the search condition, please follow below,
Supposing that the Dataset for the
@CustomerTypeCodeName’s T-SQL query is:
select
distinct customertypecodename
from FilteredAccount
Replace your current query with below expression,
="declare @counts integer select @counts=COUNT(distinct customertypecodename)
from FilteredAccount select account0.name as name, account0.accountnumber as accountnumber, account0.address1_city as address1_city, account0.address1_county as address1_county, account0.customertypecodename as customertypecodename, account0.customertypecode
as customertypecode, account0.accountid as accountid from FilteredAccount as account0
where (customertypecodename in (@CustomerTypeCodeName))
or " & Parameters!
CustomerTypeCodeName’s.Count &
=@counts
If you have any other question, please feel free to let me know.
Thanks,
Sharp Wang
Best Regards. Sharp Wang
Free Windows Admin Tool Kit Click here and download it now
June 17th, 2011 11:47pm
Hi Ali,
Thanks for your question.
Rakesh’s opinion is logical and valuable, thank you very much Rakesh.
Based on your description and your T-SQL query, it seems that there are two conditionals for the judgment, if you want to add check
Select All in the @CustomerTypeCodeName to the search condition, I will complement the solution
like below,
Supposing that the Dataset for the
@CustomerTypeCodeName’s T-SQL query is:
select
distinct customertypecodename
from FilteredAccount
Replace your current query with below expression,
="declare @counts integer select @counts=COUNT(distinct customertypecodename) from FilteredAccount
select account0.name as name, account0.accountnumber as accountnumber, account0.address1_city as address1_city, account0.address1_county as address1_county, account0.customertypecodename as customertypecodename, account0.customertypecode as customertypecode,
account0.accountid as accountid from FilteredAccount as account0
where (customertypecodename in (@CustomerTypeCodeName))
or " & Parameters!
CustomerTypeCodeName’s.Count &
=@counts
If you have any other question, please feel free to let me know.
Thanks,
Sharp Wang
Best Regards. Sharp Wang
June 18th, 2011 6:44am