Consider a table in SQL Server has a column Item
, I tried to created a query to covert all values in the column into a single cell result into comma separated string, for example:
Table:
| Item |
--------
| milk |
| sugar|
| salt |
| .... |
Query result:
| Item List |
---------------------------
| milk, sugar, salt ..... |
It would be better to have some customization as
| Item List |
----------------------------------------------------
| milk as milk, sugar as sugar, salt as salt ..... |
I saw there is option as unpivot
however it has to be definitive amount of values in the column. Just wondering any available functions to support this goal if target column value is dynamic