SELECT A.CompName,a.Mobile,a.CountryName,a.ProvinceName,a.CityName, B.address, a.type,a.TEL,a.time,a.lat,a.lng,a.isForgen,a.RemarkContent FROM( select v.CompName,v.Mobile,v.CountryName,v.ProvinceName,v.CityName,Address=CONVERT(xml,'<root><v>' + REPLACE(v.address, ';', '</v><v>') + '</v></root>'), '' type,v.mobile TEL,'' time,'' lat,'' lng,'' isForgen,r.RemarkContent from Cu_VisitorFair f left join Cu_Visitor v on v.VisitorID=f.VisitorID left join Cu_VisitorRemark r on r.VisitorID=f.VisitorID and f.FairID=r.FairID where f.FairID=1652 )A OUTER APPLY( SELECT address = N.v.value('.', 'varchar(100)') FROM A.Address.nodes('/root/v') N(v) )B
参考博考 https://www.cnblogs.com/wwHww/p/13671447.html