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

  • Home
  • SEARCH
  • 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 6069539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:50:00+00:00 2026-05-23T09:50:00+00:00

Possible Duplicates: T-SQL stored procedure that accepts multiple Id values Parameterizing a SQL IN

  • 0

Possible Duplicates:
T-SQL stored procedure that accepts multiple Id values
Parameterizing a SQL IN clause?

I have a stored procedure who have to select values with a filter system.
Imagine a Table

ColA | ColB | ColC |

'A'    12     1
'B'    13     2
'C'    14     3

I need to give to stored procedure a list of ColC values for those a want the values, example (1,3)
will give me ‘A’ and ‘C’.

I know it is possible to do a IN statement like :

Select *
from Table
where ColC in (1,3)

But how make this dynamic? a solution will be to construct the sql command in a Varchar variable like

SET @MyList ='(1,3)'
SET @SQL = '
     Select *
    from Table
    where ColC in ' + @MyList 

And then execute @SQL

But is it the best way? To make dynamic command like this is not too heavy?

Thanks for advices.

  • 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-23T09:50:00+00:00Added an answer on May 23, 2026 at 9:50 am

    There are plenty of different options on how to pass arrays to stored procedures, however, the common practice is building the query like you have shown, hence I think it’s the best solution here.

    EDIT: Arrays in SQL 2008 still shows building a query as the first approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Parameterizing a SQL IN clause? Hi, I have a query looks like
Possible Duplicates: SQL Multiple Parameter Values SQL Server (2008) Pass ArrayList or String to
Possible Duplicate: Scheduled run of stored procedure on SQL server I have a stored
Possible Duplicates: Is there an Oracle SQL query that aggregates multiple rows into one
I have an xml document that is stored in sql server 2005 that I
Possible Duplicates: Linq to Entities - Sql “IN” clause How to implement SQL “in”
Possible Duplicate: Split string in SQL I have seen a couple of questions related
Possible Duplicate: What are the pros and cons to keeping SQL in Stored Procs
Possible Duplicate: SQL: Using Select * Hi everyone! I wonder if it is really
Possible Duplicate: Need help with a SQL query that combines adjacent rows into a

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.