THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

Jamie Thomson

This is the blog of Jamie Thomson, a freelance data mangler in London

SSRS Helper Code : Convert a multivalue parameter to a comma delimited string

Occasionally I use this blog to post bits of code that I might, one day, need again and justify it by telling myself that someone else, somewhere, might need one day need the same as well. This is one such blog post.

The following code converts a multivalue parameter in SQL Server Reporting Services into a comma delimited list:


Public Function ConvertMultivalueParameterToCommaDelimitedList(ByVal Parameter as Parameter) as String Dim s as String If parameter.IsMultiValue then s = "" For i as integer = 0 to parameter.Count-1 s = s + CStr(parameter.Value(i)) If i <> parameter.Count-1 Then s = s + "," Next Else s = "Single value: " + CStr(parameter.Value) End If Return s End Function

 

Thank you to Ostrosoft for their VB code-to-HTML converter.

That is all!!

@Jamiet

UPDATE: Turns out that there is a function in SSRS’s expression language that does this for you. Its called Join and you can read more about it on Luke Hayler’s blog post The JOIN() Function in SSRS. Thanks to KD and Dave in the comments!

Published Sunday, August 08, 2010 10:43 PM by jamiet

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

KD said:

Why not use the Join function?

August 9, 2010 8:19 AM
 

Dave J said:

I second KD's comment - Join does it for you and will let you choose the delimiter you want, so why reinvent the wheel?

August 9, 2010 8:50 AM
 

jamiet said:

"Why not use the Join function?"

Because I don't know about it. Can you point me in the right direction?

cheers

Jamie

August 9, 2010 8:56 AM
 

jamiet said:

August 9, 2010 8:59 AM
 

SSIS Junkie : SSRS Helper Code : Convert a multivalue parameter to a comma delimited string said:

August 9, 2010 3:54 PM
 

Surya Narayana said:

Thanks a lot!!!!!!!!!!!!!!!>.......................

Good code.............

March 10, 2011 7:13 AM

Leave a Comment

(required) 
(required) 
Submit

This Blog

Syndication

Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement