Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sql server xml查询?_Xml_Sql Server 2005 - Fatal编程技术网

sql server xml查询?

sql server xml查询?,xml,sql-server-2005,Xml,Sql Server 2005,如果我有如下XML:(作为XML变量names@nodes) 但我能得到的似乎是空的你的方法对我有效 下面是我如何将XML分配给变量的 declare @nodes as xml set @nodes = '<Nodes> <Item>Value 5</Item> <Item>Localhost</Item> <Item>Unrouteable - 10.x.x.x</Item>

如果我有如下XML:(作为XML变量names@nodes)


但我能得到的似乎是空的

你的方法对我有效

下面是我如何将XML分配给变量的

declare @nodes as xml 
set @nodes = '<Nodes>
    <Item>Value 5</Item>
    <Item>Localhost</Item>
    <Item>Unrouteable - 10.x.x.x</Item>
    <Item>Unrouteable - 172.16-31.x.x</Item><Item>Unrouteable - 192.168.x.x</Item>
</Nodes>'

SELECT
@nodes.value('(/Nodes/Item)[2]', 'nvarchar(255)')
将@nodes声明为xml
设置@nodes=
价值5
本机
不可路由-10.x.x.x
不可路由-172.16-31.x.xUnRoute-192.168.x.x
'
挑选
@nodes.value('(/nodes/Item)[2]','nvarchar(255)'

啊,该死。。当我粘贴示例时,我做了一些更改。。我想我当时一定把它修好了。谢谢
  SELECT
@result = @nodes.value('(/Nodes/Item)[2]', 'nvarchar(255)')
declare @nodes as xml 
set @nodes = '<Nodes>
    <Item>Value 5</Item>
    <Item>Localhost</Item>
    <Item>Unrouteable - 10.x.x.x</Item>
    <Item>Unrouteable - 172.16-31.x.x</Item><Item>Unrouteable - 192.168.x.x</Item>
</Nodes>'

SELECT
@nodes.value('(/Nodes/Item)[2]', 'nvarchar(255)')