Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Concate Set Of Rows With Comma (or Any) In A Single String

DZone's Guide to

Concate Set Of Rows With Comma (or Any) In A Single String

·
Free Resource
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.

Spring Framework
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}