Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to coalesce many rows into one?

$
0
0

I am using SSMS 2008 R2 and am simply trying to coalesce many rows into one. This should be simple I think, but it is currently repeating data in each row. Consider:

createtable test(
Name varchar(30))insert test values('A'),('B'),('C')select*from testselectdistinct Name,coalesce(Name +', ','')from test 

How can I rewrite this to achieve one row like: A,B,C


Ryan D


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>