選擇我通過XML查詢
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>'
我嘗試做一個腳本,返回這樣
Number_0
Number_1
Number_2
Number_3
我該怎麼辦呢非XML輸出?
我嘗試
SELECT
good.value('@Number', 'nvarchar(50)') as Number
FROM @xml_var.nodes('/Text') col(Text)
我沒有訪問SQL Server現在,這將是以後
OK,我的解決方案,但是當我嘗試
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小提琴錯誤出現
解決方案「我現在無法訪問sql server」 - > http://sqlfiddle.com –