Click here to Skip to main content
Click here to Skip to main content

Tagged as

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.
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 | [Rose]


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


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
  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...
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

GeneralMy vote of 5 PinmemberSavalia Manoj M7-Nov-12 2:13 
GeneralRe: My vote of 5 PinprofessionalSunasara Imdadhusen22-Apr-14 5:00 
GeneralMy vote of 3 PinmemberRavi Tuvar5-Nov-12 21:27 
GeneralRe: My vote of 3 PinprofessionalSunasara Imdadhusen22-Apr-14 5:00 
GeneralAlternative PinmemberPIEBALDconsult6-Jul-12 8:39 
GeneralRe: Alternative PinprofessionalSunasara Imdadhusen22-Apr-14 4:59 
GeneralReason for my vote of 4 good one Pinmembernikhi _singh16-Feb-12 18:56 
GeneralRe: Reason for my vote of 4good one PinprofessionalSunasara Imdadhusen22-Apr-14 4:59 
GeneralThanks for your vote! PinmemberSunasara Imdadhusen13-Jul-11 22:30 
GeneralReason for my vote of 5 nice PinmemberAjit Yagnesh13-Jul-11 22:23 
GeneralRe: Reason for my vote of 5nice PinprofessionalSunasara Imdadhusen22-Apr-14 4:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web01 | 2.8.150327.1 | Last Updated 5 Oct 2010
Article Copyright 2010 by Sunasara Imdadhusen
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid