Hi,
I tried running the CTE found in the link you provided. I see how this applies, but I haven't been successful toying around with substituting a carriage return for the comma.
For example I tried the following--what am I doing wrong? I realize I'm not properly understanding the commalist = subquery, but intuit that char(13) may be in conflict or I'm not using it correctly.
Thx
WITH CTE AS
(
SELECT DISTINCT
AccountNumber
FROM #TestData
)
SELECT AccountNumber,
CommaList = STUFF((
--SELECT ',' + Value
SELECT CHAR(13) + Value
FROM #TestData
WHERE AccountNumber = CTE.AccountNumber
ORDER BY Value
FOR XML PATH(''),
TYPE).value('.','varchar(max)'),1,1,'')
FROM CTE
ORDER BY AccountNumber;