I know that this is a repost of an older article from 2011 and that there have been some new functionality introduced in recent version. I have used the FOR XML and STUFF() method many times and it is great, it has really saved my bacon on a few occasions. This was why I was glad to find the introduction of the STRING_AGG() function is SQL Server 2017. With this function you can replace the entire second part of the script from "WITH CTE" down with the following.
STRING_AGG(Value,',') AS CommaList
GROUP BY AccountNumber
ORDER BY AccountNumber;
I hope that those of you lucky enough to have an up to date system will find this easier.