select stuff((select ','+A.CarType from (select distinct CarType from #tempCarType) A FOR xml PATH('')), 1, 1, '') as CarType
#tempCarType为表名,CarType为字段名
SQL将一列多行数据转换为一行
最新推荐文章于 2025-10-14 21:05:41 发布
本文介绍了一种使用 SQL 语句结合 FOR XML 路径方法来处理特定表 #tempCarType 中 CarType 字段数据的技术。通过巧妙构造查询语句,可以实现将多个 CarType 值组合成符合 XML 规范的字符串形式。

1078

被折叠的 条评论
为什么被折叠?



