--行转列 固定xml语法 declare @xml xml ; set @xml=cast('<v>2</v><v>4</v><v>3</v><v></v>' as xml); select tab.val.value('.'/*xpath 语法*/,'nvarchar(100)') d from @xml.nodes('/v') tab(val) --outer apply 是可以用到前面表的变量 select * from (select cast('<v>2</v><v>4</v><v>3</v><v></v>' as xml) c) a cross apply(select tab.val.value('.','nvarchar(100)') d from a.c.nodes('/v') tab(val)) b