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 105815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:29:55+00:00 2026-05-11T01:29:55+00:00

I need to filter result sets from sql server based on selections from a

  • 0

I need to filter result sets from sql server based on selections from a multi-select list box. I’ve been through the idea of doing an instring to determine if the row value exists in the selected filter values, but that’s prone to partial matches (e.g. Car matches Carpet).

I also went through splitting the string into a table and joining/matching based on that, but I have reservations about how that is going to perform.

Seeing as this is a seemingly common task, I’m looking to the Stack Overflow community for some feedback and maybe a couple suggestions on the most commonly utilized approach to solving this problem.

  • 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. 2026-05-11T01:29:56+00:00Added an answer on May 11, 2026 at 1:29 am

    I solved this one by writing a table-valued function (we’re using 2005) which takes a delimited string and returns a table. You can then join to that or use WHERE EXISTS or WHERE x IN. We haven’t done full stress testing yet, but with limited use and reasonably small sets of items I think that performance should be ok.

    Below is one of the functions as a starting point for you. I also have one written to specifically accept a delimited list of INTs for ID values in lookup tables, etc.

    Another possibility is to use LIKE with the delimiters to make sure that partial matches are ignore, but you can’t use indexes with that, so performance will be poor for any large table. For example:

    SELECT      my_column FROM      My_Table WHERE      @my_string LIKE '%|' + my_column + '|%' 

    .

    /*     Name:       GetTableFromStringList     Description:    Returns a table of values extracted from a delimited list     Parameters:             @StringList - A delimited list of strings             @Delimiter - The delimiter used in the delimited list      History:     Date        Name            Comments     ----------  -------------   ----------------------------------------------------     2008-12-03  T. Hummel   Initial Creation */ CREATE FUNCTION dbo.GetTableFromStringList (     @StringList VARCHAR(1000),     @Delimiter  CHAR(1) = ',' ) RETURNS @Results TABLE (     String  VARCHAR(1000)   NOT NULL ) AS BEGIN     DECLARE         @string     VARCHAR(1000),         @position   SMALLINT      SET @StringList = LTRIM(RTRIM(@StringList)) + @Delimiter     SET @position = CHARINDEX(@Delimiter, @StringList)      WHILE (@position > 0)     BEGIN         SET @string = LTRIM(RTRIM(LEFT(@StringList, @position - 1)))          IF (@string <> '')         BEGIN             INSERT INTO @Results (String) VALUES (@string)         END          SET @StringList = RIGHT(@StringList, LEN(@StringList) - @position)         SET @position = CHARINDEX(@Delimiter, @StringList, 1)     END      RETURN END 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer For the Java world: Parsers JavaCC Antlr Indexer Apache Lucene… May 11, 2026 at 11:49 am
  • added an answer Really, you just compare the string to whatever you expect… May 11, 2026 at 11:49 am
  • added an answer You can save your variable in the function, using either… May 11, 2026 at 11:49 am

Related Questions

I need to filter result sets from sql server based on selections from a
I need to filter out anchor tags in a string. For instance, Check out
I want to filter the selectable dates on a datepicker. I basically need to
I have a query filter written in human readable language. I need to parse
I need to know about Epoll On linux System. Could you recommend manual or
I need to copy hundreds of gigs of random files around on my computer
I need to send hundreds of newsletters, but would like to check first if
I need to launch a server on the remote machine and retrieve the port
I need to add a web part zone to a wiki page. I'm opening
I need to create a historical timeline starting from 1600's to the present day.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.