我只是在学习 XQUERY 并试图完成我认为非常简单的事情.这是我的 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)
我不知道如何查询内部元素 appversion.我没有收到任何错误,但我无法在 appversion 内部元素中返回 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?
如果您只想要一行,则无需使用 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
这篇关于T-SQL、XQuery 无效列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!