问题描述
|
我将来自Google Geocoding API的XML响应存储在SQL Server XML列中。有人可以帮助我进行查询,该查询将返回XML包含> 1个结果的所有行吗?
例如
<GeocodeResponse>
<status>OK</status>
<result></result> <!-- more than one result is present -->
<result></result>
<result></result>
</GeocodeResponse>
所以这样的事情给了我第一个结果:
SELECT XmlResponse.query(\'/GeocodeResponse/result\') FROM Locations
但是我不确定从这里去哪里...
解决方法
您可以使用XML数据类型的exist()方法来检查是否存在第二个“ 2”节点。
select *
from Locations
where XmlResponse.exist(\'GeocodeResponse/result[2]\') = 1
在此处测试查询。 http://data.stackexchange.com/stackoverflow/q/101340/xmlcolumn-exist