Click here to Skip to main content
12,507,376 members (69,934 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

11.5K views
10 bookmarked
Posted

Concatenate two or more rows with comma (or any you want) in a single string

, 4 Oct 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Hi
I would like to share cool feature of SQL Server with you guys like:

Please use the following query when concatenate two or more rows with comma (or any you want) in a single string.
SELECT STUFF((SELECT ',' + RTRIM(RegionDescription) FROM Region FOR XML PATH('')),1,1,'') AS 'Regions'

This would be also useful when you have to check between condition in SQL Query.

Please do let me know, if you have any doubt.

Please provide "Vote" if this would be helpful. :rose:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sunasara Imdadhusen
Software Developer (Senior) Infostretch Ahmedabad-Gujarat
India India
Aspiring for a challenging carrier wherein I can learn, grow, expand and share my existing knowledge in meaningful and coherent way.

sunaSaRa Imdadhusen

AWARDS:
  1. 2nd Best Mobile Article of January 2015
  2. 3rd Best Web Dev Article of May 2014
  3. 2nd Best Asp.Net article of MAY 2011
  4. 1st Best Asp.Net article of SEP 2010

Read More Articles...

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralMy vote of 5 Pin
Savalia Manoj M7-Nov-12 1:13
memberSavalia Manoj M7-Nov-12 1:13 
GeneralRe: My vote of 5 Pin
Sunasara Imdadhusen22-Apr-14 4:00
professionalSunasara Imdadhusen22-Apr-14 4:00 
GeneralMy vote of 3 Pin
Ravi Tuvar5-Nov-12 20:27
memberRavi Tuvar5-Nov-12 20:27 
GeneralRe: My vote of 3 Pin
Sunasara Imdadhusen22-Apr-14 4:00
professionalSunasara Imdadhusen22-Apr-14 4:00 
GeneralAlternative Pin
PIEBALDconsult6-Jul-12 7:39
memberPIEBALDconsult6-Jul-12 7:39 
GeneralRe: Alternative Pin
Sunasara Imdadhusen22-Apr-14 3:59
professionalSunasara Imdadhusen22-Apr-14 3:59 
GeneralReason for my vote of 4 good one Pin
nikhi _singh16-Feb-12 17:56
membernikhi _singh16-Feb-12 17:56 
GeneralRe: Reason for my vote of 4good one Pin
Sunasara Imdadhusen22-Apr-14 3:59
professionalSunasara Imdadhusen22-Apr-14 3:59 
GeneralThanks for your vote! Pin
Sunasara Imdadhusen13-Jul-11 21:30
memberSunasara Imdadhusen13-Jul-11 21:30 
GeneralReason for my vote of 5 nice Pin
Ajit Yagnesh13-Jul-11 21:23
memberAjit Yagnesh13-Jul-11 21:23 
GeneralRe: Reason for my vote of 5nice Pin
Sunasara Imdadhusen22-Apr-14 3:58
professionalSunasara Imdadhusen22-Apr-14 3:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160927.1 | Last Updated 5 Oct 2010
Article Copyright 2010 by Sunasara Imdadhusen
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid