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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:25:04+00:00 2026-06-01T10:25:04+00:00

How to loop through comma separated list in SQL? I have a list of

  • 0

How to loop through comma separated list in SQL? I have a list of ID’s and I need to pass these ID’s to a stored procedure. I CANNOT alter the stored procedure. I need to figure out how to execute the SP for each id. Give me some ideas, I can carry on from there.

Thanks.

  • 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-06-01T10:25:05+00:00Added an answer on June 1, 2026 at 10:25 am
    declare @S varchar(20)
    set @S = '1,2,3,4,5'
    
    while len(@S) > 0
    begin
      --print left(@S, charindex(',', @S+',')-1)
      exec YourSP left(@S, charindex(',', @S+',')-1)
      set @S = stuff(@S, 1, charindex(',', @S+','), '')
    end
    

    Try on SE Data: Walk the string

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

Sidebar

Related Questions

How can I loop through a Comma separated string which I am passing as
I need to loop through all the matches in say the following string: <a
I'm trying to loop through items of a checkbox list. If it's checked, I
I know I can loop through a list of strings like this: list<string>::iterator Iterator;
I need to loop through a set of 2-dimensional array of hidden input fields
I have a comma-separated string that I want to convert into an array, so
I have an array of strings that are comma separated such as: Steve Jobs,12,CA
I have a view called volunteer_edit. Within volunteer_edit, I use jQuery to loop through
So I need to run a loop in Ruby to pass some strings into
i need to loop through all the nodes in the xml document and append

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.