When is the ID is all selected for below table, the result should display as below result
+-----------+
| ID | Name |
+-----------+
| 1 |a |
| 2 |b |
| 3 |c |
+-----------+
Result:
Name
-----
a b c
please try below:
SELECT Name + ' ' as Name
FROM table_name
FOR XML PATH ('')
Hope it solves your problem!
If you are using SQL Server 2017 onwards. String_Agg
SELECT STRING_AGG(Name,' ') AS Name
FROM table_name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.