本文介紹了T-SQL、XQuery 無(wú)效列的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我只是在學(xué)習(xí) XQUERY 并試圖完成我認(rèn)為非常簡(jiǎn)單的事情.這是我的 T-SQL 代碼:
I'm just learning XQUERY and trying to accomplish what I thought would be very simple. Here's my T-SQL code:
DECLARE @XML xml
set @xml = '<resultsets><AppVersion>13.0</AppVersion></resultsets>'
-- Code below is wrong
select
ResultSets.AppVersion.query('AppVersion').value('.', 'varchar(100)') as AppVersion
from @XML.nodes('/resultsets/AppVersion') ResultSets(AppVersion)
我不知道如何查詢內(nèi)部元素 appversion.我沒(méi)有收到任何錯(cuò)誤,但我無(wú)法在 appversion 內(nèi)部元素中返回 13.0.有人可以幫忙嗎?
I cannot figure out exactly how to query that inner element, appversion. I'm not getting any errors, but I'm unable to return that 13.0 within the appversion inner-element. Can someone please help?
推薦答案
如果您只想要一行,則無(wú)需使用 nodes
.
If you only want one row as a result there is no need to use nodes
.
DECLARE @XML xml
set @xml = '<resultsets><AppVersion>13.0</AppVersion></resultsets>'
select @XML.value('(/resultsets/AppVersion)[1]', 'varchar(100)') as AppVersion
這篇關(guān)于T-SQL、XQuery 無(wú)效列的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!