如下字段红框里的信息都一样的,通过转换实现字段拼接
SELECT formmain_id,(SELECT field0040+';' FROM formson_5489 WHERE formmain_id=A.formmain_id FOR XML PATH('')) AS gjgzsx FROM formson_5489 A GROUP BY formmain_id order by 1