SQL Server 2005 XML 查询
我是在 SQL Server 2005 中查询 XML 数据类型的新手。任何人都可以帮助我根据我的要求创建查询吗?这是我的专栏的一个场景。
Column Name: Cabinet
/*Row 1 XML Data*/
<shelf>
<box>
<item type="pencil" color="blue"/>
<item type="pencil" color="red"/>
<item type="paper" color="white"/>
<item type="ribbon" color="red"/>
</box>
<shelf>
/*Row 2 XML Data*/
<shelf>
<item type="pencil" color="yellow"/>
<item type="can" color="blue"/>
<item type="scissor" color="yellow"/>
<shelf>
Desired Output:
4
3
我想计算“项目”节点的数量,无论其类型和类型如何。颜色。提前致谢。
I'm new to querying XML datatype in SQL Server 2005. Anyone can help me create a query for my requirement? Here's a scenario of my column.
Column Name: Cabinet
/*Row 1 XML Data*/
<shelf>
<box>
<item type="pencil" color="blue"/>
<item type="pencil" color="red"/>
<item type="paper" color="white"/>
<item type="ribbon" color="red"/>
</box>
<shelf>
/*Row 2 XML Data*/
<shelf>
<item type="pencil" color="yellow"/>
<item type="can" color="blue"/>
<item type="scissor" color="yellow"/>
<shelf>
Desired Output:
4
3
I want to count the number of "item" nodes regardless of its type & color. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这个(完整的工作示例)
Have a look at this (Full working example)