sql server 2008 - SQL XML Xquery data query using a variable in the node selection? -


i missing right in front of me, have sql 2008 xml query follows:

select distinct cast(customfields_xml.query('data(/root/cf_item_type)') varchar) c1 designs 

.. trying achieve make "cf_item_type" variable, because want pass in node param proc..

so in reality, trying end like:

(@cf passed param, declaring example use)

declare @cf varchar set @cf='cf_item_type' select distinct cast(customfields_xml.query('data(/root/@cf)') varchar) cloth designs 

.. can see trying use @cf variable within xquery statement..

any pointers/help great!!

this might want.

declare @cf varchar(20) set @cf='cf_item_type'  select distinct   cast(customfields_xml.query(     'data(/root/*[local-name(.) = sql:variable("@cf")])') varchar(20)) cloth designs 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -