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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:23:52+00:00 2026-05-31T15:23:52+00:00

Hi Dear All My friends, I want to ask one thing about sql cross

  • 0

Hi Dear All My friends,

I want to ask one thing about sql cross tab function.Currently, I am using sql 2008 express version and my table structure is like below.

UserID     Str_Value
1             A
1             B
1             C
2             A
2             B
3             D
3             E

I want to get like this .

UserID     Str_Value
1             A,B,C
2             A,B
3             D,E

I don’t want to use cursor.Is there any function for that one?
Please give me the right way.I really appreciate it.

Thanks.

Best Regards,

Chong

  • 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-31T15:23:53+00:00Added an answer on May 31, 2026 at 3:23 pm

    Hope this helps. You can comment ORDER BY T1.Str_Value if not needed and set the nvarchar(500) size as required

    SELECT DISTINCT T1.UserId,
    Stuff(
          (SELECT N', ' + T2.Str_Value 
           FROM t T2
           WHERE T2.userId = T1.userid
           ORDER BY T2.Str_Value
           FOR XML PATH(''),TYPE).value('text()[1]','nvarchar(500)'),1,2,N'') 
            AS Str_Value
    FROM t T1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear all i am using this function to get the GMT time, i am
Dear all, i want to show some data in one row from 1 column
dear all i want to know how to submit asp.net form data using jquery
Dear All, I'm using dojo.declare to create classes in JavaScript. In one of the
Dear all, I have a question about Facebook Page: ( NOT user profile page,
Dear All, please help me since I'm newbie in SQL Server. I have a
Dear all, I have a select query that currently produces the following results: DoctorName
dear all..i've a textfield, it using barcode scanner for input data..after scan it shows
dear all..i want my input form automatically make all character become big size.. and
Dear all... I've been creating my website on another PC. Now I want to

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.