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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:31:11+00:00 2026-05-19T02:31:11+00:00

I have a CheckBoxList where users can select multiple items from the list. I

  • 0

I have a CheckBoxList where users can select multiple items from the list. I then need to be able to pass these values to my Stored Procedure so they can be used in a WHERE condition like:

WHERE ID IN (1,2,3)

I tried doing this so that its a nvarchar parameter and i pass the string 1,2,3 with:

WHERE ID IN (@IDs)

But this returned the following error:

Conversion failed when converting the nvarchar value '1,2,3' to data type int

Any help would be much appreciated!

  • 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-19T02:31:12+00:00Added an answer on May 19, 2026 at 2:31 am

    There’s a few ways of doing it.
    You could pass in the parameter as an XML blob like this example:

    CREATE PROCEDURE [dbo].[uspGetCustomersXML]
        @CustomerIDs XML
    AS
    BEGIN
    SELECT c.ID, c.Name
    FROM [dbo].[Customer] c
    JOIN @CustomerIDs.nodes('IDList/ID') AS x(Item) ON c.ID = Item.value('.', 'int' )
    END
    GO
    
    --Example Use:
    EXECUTE [dbo].[uspGetCustomersXML] '<IDList><ID>1</ID><ID>10</ID><ID>100</ID></IDList>'
    

    Or pass in the values as CSV and use a split function to split the values out into a table variable (there’s a lot of split functions out there, quick search will throw one up).

    CREATE PROCEDURE [dbo].[uspGetCustomersCSV]
        @CustomerIDs VARCHAR(8000)
    AS
    BEGIN
    SELECT c.Id, c.Name
    FROM [dbo].[Customer] c
    JOIN dbo.fnSplit(@CustomerIDs, ',') t ON c.Id = t.item
    END
    GO
    
    --Example Use:
    EXECUTE [dbo].[uspGetCustomersCSV] '1,10,100'
    

    If you were using SQL 2008 or later, you could have used Table Valued Parameters which allow you to pass a TABLE variable in as a parameter. I blogged about these 3 approaches a while back, with a quick performance comparison.

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

Sidebar

Related Questions

I have the following checkboxlist. I need to uncheck rest of list items when
i have a CheckBoxList with a list of services that the user can execute...
I have a CheckBoxList that displays a list of checkboxes using data from a
I have a checkboxlist wich contains a list of services loaded from a database
I have a list of options on my site that a user can select.
I have a checkboxlist in Popup. I used a selectall checkboxlist items function in
I have the following ViewModel public class RecommendationModel { public List<CheckBoxItem> CheckBoxList { get;
I have Checkboxlist and i can't give it required field validator or custom validator.
I have an <asp:CheckBoxList> using RepeatLayout=Flow in my page I dynamically assign values to.
I have a CheckBoxList that is showing all A table C column. SELECT DISTINCT

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.