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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:03:08+00:00 2026-06-10T15:03:08+00:00

We are currently upgrading a current data import process we have written in C#.

  • 0

We are currently upgrading a current data import process we have written in C#.

As part of the upgrade process, we need to check the results of the import process from the rewrite against the results of the old system.

One of the changes we made was breaking comma-delimited lists into rows in another table. This will enable us to filter results using a simple join.

This is the old schema:

FormNumber      MainCategories
1               blue,green,red
2               yellow,red,blue
3               white

Which we normalized to:

FormNumber      AttributeId      Value
1               1                blue
1               1                green
1               1                red
2               1                yellow
2               1                red
2               1                blue
3               1                white

Now, our next step is to confirm that the results from the two processes are the same. One of these checks is to compare the MainCategories field of the old process with the results from the normalized tables.

This leads us, finally, to the question: How do I create a comma-delimited list of the new schema to compare to the value of the old.

We have tried the XMLPath solution proposed by @Ritesh here: Concatenate many rows into a single text string?

Here is the adapted sql statement:

Select distinct ST2.FormNumber, 
           (Select ST1.Value + ',' AS [text()]
            From cache.ArtifactAttribute ST1
            Where ST1.FormNumber= ST2.FormNumber
            ORDER BY ST1.FormNumber
            For XML PATH ('')) [Values]
     From cache.ArtifactAttribute ST2

The problem is the results are not correct. Even though FormNumber 1 only has three entries in the table, the Values column (the dynamically built delimited string) shows incorrect results. Obviously we are not implementing the sql code correctly.

What are we doing wrong?

  • 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-10T15:03:10+00:00Added an answer on June 10, 2026 at 3:03 pm

    Here is a way for you to try:

    SELECT DISTINCT A.FormNumber, MainCategories
    FROM YourTable A
    CROSS APPLY (SELECT STUFF((SELECT ',' + Value 
                               FROM YourTable
                               WHERE FormNumber = A.FormNumber FOR XML PATH('')),1,1,'') MainCategories) B
    

    Though there is the problem where you can’t really be sure that the order of the items concatenated is the same as the one you have, since there isn’t a column that explictly gives that order. Here is a working SQL Fiddle with this example.

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

Sidebar

Related Questions

We are currently evaluating upgrading from XP to Windows 7, but have one last
I have a problem in upgrading an old data model to a current model.
I'm currently upgrading one of my websites from the old system to HTML5 and
Here is my scenario: I am currently upgrading a web site I maintain from
I recently bought Visual Studio 2008 Professional [Upgrade] to upgrade from my current Visual
I'm currently upgrading to the new HTML5 version of Google Maps Geolocation API and
I'm looking at upgrading a POS (Point Of Sale) project which is currently built
I've got an older ASP/VBScript app that I'm maintaining/upgrading and its currently using the
Im currently uploading data to MS SQL server via SQLBulkCopy and Transactions. I would
I'm currently upgrading an older iPhone flashcard application that uses two SQLite dbs (one

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.