Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6469631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:00:57+00:00 2026-05-25T06:00:57+00:00

I’m working on a report in reporting services that has the user select a

  • 0

I’m working on a report in reporting services that has the user select a number of items from a multivalue list. The query for the report uses the resulting list in a simple

SELECT foo FROM bar WHERE foobar IN (@SelectedItemsFromMultiValueList)

I’m now altering the report and need to iterate over the items in @SelectedItemsFromMultiValueList using a cursor. I’ve looked around but can’t figure out how to do this – made even more difficult by the fact that I’m not sure what to call a list of values used in an IN or even declare one manually (eg. DECLARE @SelectedItemsFromMultiValueList ???)

Does anybody know how to cursor over a multivalue list parameter or how to call something like that in SQL so I can search more effectively for a solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:00:57+00:00Added an answer on May 25, 2026 at 6:00 am

    Your multi-value list is going to come in to sql as a list of comma separated values (i.e. “31,26,17”)

    To iterate through these values you need a way to split the values into a table. This is a function I have used, that I believe was originally coded by Jens Suessmeyer:

    CREATE FUNCTION [dbo].[ufn_split]
       (  @Delimiter varchar(5), 
          @List      nvarchar(max)
       ) 
       RETURNS @TableOfValues table 
          (  RowID   smallint IDENTITY(1,1), 
             [Value] NVARCHAR(max)
          ) 
    AS 
       BEGIN
    
          DECLARE @LenString int 
    
          WHILE len( @List ) > 0 
             BEGIN 
    
                SELECT @LenString = 
                   (CASE charindex( @Delimiter, @List ) 
                       WHEN 0 THEN len( @List ) 
                       ELSE ( charindex( @Delimiter, @List ) -1 )
                    END
                   ) 
    
                INSERT INTO @TableOfValues 
                   SELECT substring( @List, 1, @LenString )
    
                SELECT @List = 
                   (CASE ( len( @List ) - @LenString ) 
                       WHEN 0 THEN '' 
                       ELSE right( @List, len( @List ) - @LenString - 1 ) 
                    END
                   ) 
             END
    
          RETURN 
    
       END 
    

    So you call this function, passing it @SelectedItemsFromMultiValueList and it will return to you a table of values that you can then do with what you want.

    For example:

    SELECT * FROM Foo WHERE X IN (SELECT [value] FROM dbo.ufn_split(',', @SelectedItemsFromMultiValueList)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.