我有
declare @xml_var varchar(4000)
set @xml_var =
'<Text ID = "1">
<Good Number ="Number_0"/>
<Good Number ="Number_1"/>
<Good Number ="Number_2"/>
<Good Number ="Number_3"/>
</Text>'
我尝试做一个像这样返回非xml输出的脚本
Number_0
Number_1
Number_2
Number_3
我该怎么做?
我试试
SELECT
good.value('@Number', 'nvarchar(50)') as Number
FROM @xml_var.nodes('/Text') col(Text)
我现在无法访问 sql server,那将是以后
好的,我有解决方案,但是当我尝试时
declare @string varchar(8000)
declare @xml_var xml;
set @string =
'<Text ID = "1">
<Good Number ="Number_0"/>
<Good Number ="Number_1"/>
<Good Number ="Number_2"/>
<Good Number ="Number_3"/>
</Text>'
SET @xml_var = @string;
SELECT Data.Col.value('@Number', 'nvarchar(100)') AS Number
FROM @xml_var.nodes('/Text/Good') AS Data(Col)
出现 sql fiddle 错误