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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:23:42+00:00 2026-06-06T22:23:42+00:00

Hi I am trying to retrieve values from database. I have a row which

  • 0

Hi I am trying to retrieve values from database. I have a row which has multiple image names separated by “,”. I want to display them in different lines. I am using the following code which is working fine for two values. But even when I have three or more values then too it gives back only two. This is my query:

;with tmp(ImageURL,HeritageId) as
 (

select  LEFT(ImageURL, CHARINDEX(',',ImageURL+',')-1),
    STUFF(ImageURL, 1, CHARINDEX(',',ImageURL+','), '')
from shop.dbo.Images where HeritageId=@HeritageId
union all
select  right(ImageURL, CHARINDEX(',',ImageURL+',')-1),
    STUFF(ImageURL, 1, CHARINDEX(',',ImageURL+','), '')
from Images
where ImageURL > '' and HeritageId=@HeritageId
)
select  ImageURL
from tmp
  • 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-06T22:23:43+00:00Added an answer on June 6, 2026 at 10:23 pm

    Your query looks like an attempt to use a recursive CTE to split a string. It that is the case it should look something like this.

    ;with tmp(ImageURL,Rest) as
     (
    
    select  LEFT(ImageURL, CHARINDEX(',',ImageURL+',')-1),
        STUFF(ImageURL, 1, CHARINDEX(',',ImageURL+','), '')
    from Images where HeritageId=@HeritageId
    union all
    select  LEFT(Rest, CHARINDEX(',',Rest+',')-1),
        STUFF(Rest, 1, CHARINDEX(',',Rest+','), '')
    from tmp
    where Rest > ''
    )
    select  ImageURL
    from tmp
    

    Use the CTE in the recursive part instead of the table.

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

Sidebar

Related Questions

I am trying to retrieve a set of values from database and assigned it
I have a serious problem. Firstly, I am trying to retrieve values from my
I have next problem, when I'm trying to retrieve value from xforms:select elements I
I am trying to use the getIntent value(score) which is retrieve from the previous
I'm trying to make an image database which does not keep a consistent record
I am trying to fetch data from my database and when I display it
I'm trying to retrieve the @@IDENTITY value from an access database after I add
I am trying to retrieve some rows from the database using simple SELECT statement
I want to retrieve data from 2 columns of my database table and bind
I am trying to retrieve some data from a database using jQuery's $.getJSON method

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.