Click here to Skip to main content
15,885,905 members
Articles / Programming Languages / SQL
Tip/Trick

Get Column values as comma seperated string

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
19 Jan 2010CPOL 16.8K   9  
Ever wondered that how to get a comma (pipe or whatever) seperated result for a column in a table.The following statement show a simple example you can take as a starting point.Select (Stuff((Select ', ' + FName From Accounts FOR XML PATH('')),1,2,''))
Ever wondered that how to get a comma (pipe or whatever) seperated result for a column in a table.

The following statement show a simple example you can take as a starting point.

Select (Stuff((Select ', ' + FName From Accounts FOR XML PATH('')),1,2,''))

License

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


Written By
Architect
Netherlands Netherlands

Read my personal blog at www.manasbhardwaj.net.


Comments and Discussions

 
-- There are no messages in this forum --