SQL XML Xquery 在节点选择中使用变量进行数据查询?
我显然错过了我面前的一些东西,但是我有这个 SQL 2008 XML 查询,如下所示:
select distinct cast(customFields_xml.query('data(/root/cf_item_type)') as varchar) as c1
from designs
..我实际上想要实现的是使“cf_item_type”成为一个变量,因为我想将节点传递为过程的参数..
所以实际上,我试图得到类似的结果:
(@cf将作为参数传递,但声明例如使用)
declare @cf varchar
set @cf='cf_item_type'
select distinct cast(customFields_xml.query('data(/root/@cf)') as varchar) as cloth from designs
..所以你可以看到我正在尝试使用@比照xquery 语句中的变量..
任何指针/帮助都会很棒!
I am obviously missing something right in front of me, however I have this SQL 2008 XML query as follows:
select distinct cast(customFields_xml.query('data(/root/cf_item_type)') as varchar) as c1
from designs
.. what I am actually trying to achieve is to make the "cf_item_type" a variable, because I want to pass in the node as a param to a proc..
So in reality, I am trying to end up with something like:
(@cf would be passed as a param, but declaring for example use)
declare @cf varchar
set @cf='cf_item_type'
select distinct cast(customFields_xml.query('data(/root/@cf)') as varchar) as cloth from designs
.. So you can see I am trying to use the @cf variable within the xquery statement..
Any pointers/help would be great!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能会做你想做的事。
This might do what you want.