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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:37:29+00:00 2026-05-20T16:37:29+00:00

I have a function in my .NET application, that needs to do a search

  • 0

I have a function in my .NET application, that needs to do a search of an unknown number of parameters.

for example: select * from tbl where x=1 or x=2 or x=3 or x=4

is it possible to do in .NEt and SQL? how do i go about creating dynamic parameters in .NET (I was thinking doing it with a loop) but then how do i declare them in my stored procedure? does sql have arrays?

please help.

thank you!

  • 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-20T16:37:29+00:00Added an answer on May 20, 2026 at 4:37 pm

    You can pass in a comma seperated list, use a table function to split that out into a table and then use an IN clause. This article goes over doing that.

    table function:

    CREATE FUNCTION dbo.funcListToTableInt(@list as varchar(8000), @delim as varchar(10))
    RETURNS @listTable table(
      Value INT
      )
    AS
    BEGIN
        --Declare helper to identify the position of the delim
        DECLARE @DelimPosition INT
    
        --Prime the loop, with an initial check for the delim
        SET @DelimPosition = CHARINDEX(@delim, @list)
    
        --Loop through, until we no longer find the delimiter
        WHILE @DelimPosition > 0
        BEGIN
            --Add the item to the table
            INSERT INTO @listTable(Value)
                VALUES(CAST(RTRIM(LEFT(@list, @DelimPosition - 1)) AS INT))
    
            --Remove the entry from the List
            SET @list = right(@list, len(@list) - @DelimPosition)
    
            --Perform position comparison
            SET @DelimPosition = CHARINDEX(@delim, @list)
        END
    
        --If we still have an entry, add it to the list
        IF len(@list) > 0
            insert into @listTable(Value)
            values(CAST(RTRIM(@list) AS INT))
    
      RETURN
    END
    GO
    

    Then your stored proc can do this:

    SELECT *
    FROM tbl 
    WHERE id IN (
                SELECT Value
                FROM funcListToTableInt(@ids,',')
                       )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application in vb.net that starts with a sub function do some
I currently have a single application that needs to be started from a windows
I have an ASP.Net application that needs needs to have some work performed by
We have a VB.NET program that needs to periodically call a function in an
I am working on an asp.net MVC 3 application. I have a C# function
Say I have a function that does the following in Vb.net For i as
In .NET, the Generics Lists have a sort function that accepts IComparer or Comparison
Does .NET have some type of built in function that allows filtering on Gridviews?
I am developing a commercial VB.net WPF application that needs user generated scripts for
I have an asp.net MVC3 application that makes Ajax calls to the server on

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.