Sql一行拆分转多行

时间:2022-01-21 19:22:19
select   
    a.planid,b.mias,0 miaid  into [1_cache3]
from   
    (select planid,mias=convert(xml,'<root><v>'+replace(mias,',','</v><v>')+'</v></root>') from [1_cache1])a  
outer apply  
    (select mias=C.v.value('.','nvarchar(100)') from a.mias.nodes('/root/v')C(v))b  order by  a.planid

代码就这么简单,备忘