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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:37:18+00:00 2026-05-28T04:37:18+00:00

I have a 2 column table with 2 IDs, each pair being unique. I

  • 0

I have a 2 column table with 2 IDs, each pair being unique. I would love to find a way to create a comma separated list for each instance of the first column, IE:

IDcolumn1value1 | IDColumn2value1, IDColumn2Value2, IDColumn2Value3; IDcolumn1value2 | IDcolumn2Value2, IDcolumn2Value4

I could create a cursor, and iterate over every single item in IDcolum1, but given that there are ~8k pairs, that might not be most efficient.

Currently I have:

DECLARE @listStr VARCHAR(MAX)
SELECT  @listStr = COALESCE(@listStr+',' , '') + Component_Softpaq.SoftpaqNumber
FROM         Softpaq_SKU INNER JOIN
    ComponentVersion ON Softpaq_SKU.ComponentVersionID = ComponentVersion.ComponentVersionID INNER JOIN
    ComponentPass ON ComponentVersion.ComponentVersionID = ComponentPass.ComponentVersionID INNER JOIN
    Component_Softpaq ON ComponentPass.ComponentPassID = Component_Softpaq.ComponentPassID
group by Softpaq_SKU.SKUID, Component_Softpaq.SoftpaqNumber

SELECT @listStr
  • 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-28T04:37:19+00:00Added an answer on May 28, 2026 at 4:37 am

    You can use FOR XML PATH to generate a comma delimited list without cursors. Check out this article

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

Sidebar

Related Questions

I have a table column where each row has one of three states, and
If I have a table column with data and create an index on this
I have a really long 3 column table. I would like to <table> <tr><td>Column1</td><td>Column2</td></tr>
I have a table that stores transaction information. Each transaction is has a unique
I have an HTML table where each row represents a company and each column
I have a simple table with autoincrementing ID's and one text column. id(int), value(nvarchar)
Suppose I have a 2 column table (id, flag) and id is sequential. I
MS SQL Server 2000 I have a column in Table A called Name. I
I'm creating a 'similar items' link table. i have a 2 column table. both
I have a table column that needs to be limited to a certain width

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.