|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 3:13 PM
Points: 6,386,
Visits: 8,286
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, February 22, 2012 6:30 AM
Points: 1,
Visits: 106
|
|
Maybe I have missed something or you are talking about a totally different thing but when I use a multi-select in SSRS I just use the parameter like this:
SELECT Columns FROM Table WHERE Column1 IN (@MultiParam)
no?
|
|
|
|
|
SSCertifiable
       
Group: Moderators
Last Login: Tuesday, June 11, 2013 6:34 AM
Points: 6,463,
Visits: 1,388
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 24, 2013 8:48 PM
Points: 1,
Visits: 107
|
|
| What if the user doesn't choose any values because they don't want to filter the report on this parameter? I believe this solution would return no data to the report instead of all.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, October 12, 2009 6:26 AM
Points: 4,
Visits: 25
|
|
| Thank you for your posting, it is very helpful. Just want to point out when setting the return value of the function to the dataset parameter, it needs to reference the Code class(i.e. =Code.ReturnXML(....)).
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, June 13, 2013 8:26 AM
Points: 257,
Visits: 160
|
|
Yes.. SSRS doesn't function with passing multivalue params to procs out of the box.. however, with some minor code efforts you can do it..
if you wanted to build a report off of the northwind db to pick customers from multiple countries..
where the proc to take in and parse multivalues.. I am sure it could use work..
Anyway.. I never though of using XML.. thanks for the tip
create proc [dbo].[multivalueinputproc] (@country nvarchar(1024)=null) as set nocount on declare @countrytable table(Code nvarchar(75))
if IsNull(@country, '')='' Begin set @country='ALL' End --print @country Else While Len(@country) > 0 Begin If patindex('%,%', @country)> 0 Begin insert into @countrytable values (rtrim(substring(@country, 1, patindex('%,%', @country)-1))) set @country = ltrim(substring(@country, patindex('%,%', @country)+1, 1024)) End Else Begin insert into @countrytable values (ltrim(rtrim(@country))) break End End --print @country if (select @country) = 'ALL' Begin select * from customers End Else Begin select * from customers where country in (select * from @countrytable) Order by country End
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 09, 2008 8:14 AM
Points: 1,
Visits: 4
|
|
| This is the same method I use and it works perfectly everytime
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Tuesday, June 11, 2013 5:01 AM
Points: 4,814,
Visits: 1,343
|
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Today @ 2:01 PM
Points: 62,
Visits: 244
|
|
| I get an error - Next control variable does not match For Loop control variable 'sParamItem' should I be customizing any of the function in the code property?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 3:13 PM
Points: 6,386,
Visits: 8,286
|
|
lklein (5/8/2008) I get an error - Next control variable does not match For Loop control variable 'sParamItem' should I be customizing any of the function in the code property?
This is the exact code I'm using in my library:
Public Shared Function ReturnXML(ByVal MultiValueList As Object, ByVal Root As String, ByVal Node As String, ByVal Element As String) As String '************************************************************************** ' Returns an XML string by using the specified values. ' Parameters: ' MultiValueList - a multi value list from SSRS ' Root, Node, Element - String to use in building the XML string '************************************************************************** Dim ReturnString = "" Dim sParamItem As Object ReturnString = " " For Each sParamItem In MultiValueList ReturnString &= " " Next ReturnString &= " " Return (ReturnString) End Function
to use in the Code section of the report, remove the "public shared"
Wayne Microsoft Certified Master: SQL Server 2008 If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it! Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines, CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
|
|
|
|