摘要:
Sql 合并行如下:IDName1Tom1John2Carrier2Wendy1Rick要求显示下列结果IDName1Tom,John,Rick2Carrier,WendySql:select id,(SELECT STUFF(b.v.value('/r[1]','varchar(100)'),1,1,'')FROM(SELECT v=(SELECT ',' + Name FROM TableName where id=c.idFOR XML PATH(''),ROOT('r'),TYPE)) b) 阅读全文