SQL Server 根据某一列进行分割,并拆分成多行

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

posted @ 2021-02-19 14:31  #不归路#。。。。  阅读(521)  评论(0编辑  收藏  举报