I have a parameter called VoucherType that can multiple values selected by the user at run time. There’s a field within the table called Voucher that starts with the VoucherType and ends with a sequence of numbers that I don’t care about. For example:
VoucherTypes
- MKE
- ORD
- LAX
Vouchers
- MKE-3849284
- MKE-4173942
- ORD-1654951
- LAX-8798484
The SQL query I have to start looks like this:
SELECT VOUCHER, COST
FROM VOUCHERDATA
WHERE VOUCHER LIKE @VoucherType + '%';
However, it does not support the user selecting multiple values. When they attempt to select multiple values, they get this message:
Query execution failed for dataset ‘Dataset1’. Incorrect syntax near ‘,’.
I’m sure this is because @VoucherType is now a comma delimited list, but I have no clue how to handle it.
Any help would be appreciated, thanks!
**Note: Table changes are not feasible due to outside constraints.
There are 2 things you can do in this instance.
First of all you are correct, it is not accepting it because it is now a comma seperated list.
Basically what you need to do is parse out that comma seperated list and use a function with an IN clause in your main query. Here’s a very good article explaining how to do this:
http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/ssrs_multi_value_parameters
Otherwise another method would be to return everything in your SQL code and filter on the SSRS side. The way to do this would be to remove your where clause in SQL which filters your vouchers. This will then bring back all vouchers. In SSRS then set up a parameter the same way you normally would for a multi select parameter. Then in SSRS design view, you right click your table and go to properties. There is then a tab called filters. You can set up the filter here by saying do not show these vouchers. Basically it hides them.
The first way I explanined is definitely the best way to do it as it is faster and can be re-used in the long run. It is very simple once all the function are setup.