Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 28687

Multi-value list passing in wild card search using user prompt parameter SSRS 2008 r2(text box)is showing incorrect o/p when retrieving values

$
0
0

Function and procedure definition

Create a Table valued function in SQL Functions as below Step 1 CREATE FUNCTION [dbo].[FnSplit] ( @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 CREATE proc ProcedureName @lists varchar(2000) as DECLARE @SQL NVARCHAR(4000) = 'SELECT Table_name.* FROM Table_name WHERE ' SELECT @SQL=@SQL+ STUFF((SELECT filter+'' FROM (SELECT DISTINCT 'OR NUM LIKE ''%'+value+'%''' AS filter FROM dbo.FNSPLIT(@lists,','))T FOR XML PATH('')),1,2,'') EXEC SP_EXECUTESQL @SQL GO

I have 2 ssrs parameters text boxes 

1. Accepts a list of values 

2.Other box shows the result.

The data is always in the following varchar format- 'xyz123456' or 'xyz76859-12345'

With the above function we split and pass the data to sp which retrieves the result and shows to the user

E.G 

Right now the o/p 

when we pass single value -xyz123456 we get xyz123456

when we pass xyz we get a all the available xyz values .

When we pass a  comma separated list continous -(xyz123456 ,xyz76859-12345 )we get the xyz123456 ,xyz76859-12345 output shown in drop down box

However when we pass comma separated list (because of the muti-value parameters which allows newline ) text box 

xyz123456, (new line for illustration)
xyz76859-12345(newline for illustration)

 the o/p

we get all other values including the ones which we pass e,g .

xyz123456
xyz76859-12345

xyz563456

xyz333456

We are trimming the user prompt parameter- VarCode which we are passing to the dataset which calls the sp using the 

=ltrim(rTrim(Join(Parameters!VarCode.Value,","))) but even then we are facing unwanted o/p?







Viewing all articles
Browse latest Browse all 28687

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>