Is there any good way to build a comma-separated list in SQL Server?

纵然是瞬间 提交于 2019-12-06 06:10:01

No, those are the workarounds you will have to use. We have been asking for a GROUP_CONCAT equivalent since 2006:

http://connect.microsoft.com/SQLServer/feedback/details/247118/sql-needs-version-of-mysql-group-concat-function

...but the item has only received 13 up-votes (and one down-vote). So I don't exactly blame Microsoft for focusing on other enhancements to the product in order to drive sales and customer satisfaction. Not a lot of people have complained (at least not directly), and GROUP_CONCAT is not something the marketing people can make look sexy on a slide deck or in a commercial - developer productivity is not exactly what sells licenses. (On the other hand, I'd like to meet the 14+ people who managed to get silly things like EOMONTH and IIF implemented.)

So, if you think this functionality is important to have, then please vote and, more importantly, comment on how this will improve your productivity / bottom line:

FWIW, the XML version is ugly, but it is not hard to master. I've used it in dozens of answers here on SO and I don't even have to go look it up anymore. I also don't find it to be terribly slow. Why do you think something Microsoft puts in natively will be any faster? It will have to do essentially the same thing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!