How to use GROUP BY to concatenate strings in SQL Server?

前端 未结 20 2509
无人及你
无人及你 2020-11-21 04:33

How do I get:

id       Name       Value
1          A          4
1          B          8
2          C          9

to

id               


        
20条回答
  •  情歌与酒
    2020-11-21 04:52

    Eight years later... Microsoft SQL Server vNext Database Engine has finally enhanced Transact-SQL to directly support grouped string concatenation. The Community Technical Preview version 1.0 added the STRING_AGG function and CTP 1.1 added the WITHIN GROUP clause for the STRING_AGG function.

    Reference: https://msdn.microsoft.com/en-us/library/mt775028.aspx

提交回复
热议问题