sql server - XPATH Get list item with ID held in sibling -


To use XPath in T-SQL, I am trying to get an attribute value from the option list where the ID is to select the correct list. I / O

Any help would be appreciated.

  inserted into my mytable table (pk int primary key identification (1,1), myXML xml) into the @myTable values ​​('Fields & gt; & lt; Field ID = " 1111 "& gt; Details & gt; Now Brown Cow & lt; / description & gt; value & gt; 3 & lt; / pricing & gt; & lt; option & gt; & lt; Option & gt; Option; OptionContent = "Select one" OptionID = "- 1" /> Option  

  id details value actual approximate ----------------- -------- ------ -------- -------- 1111 Now, Br3, tap Saturn 2222, Fu Bar, 2 tap.  

change

  (./options / options / Option [@OptionID = "- 1"] / @ option content) [1]  

  $ id go to: = ./Value[1 ] Return (./Options/Options/Option[@OptionID=$id]/@OptionContent)[1]  

Your query should be

  MyField.ref.value ('@ id', 'small') as [id], myField.ref.value ('(. [Description], [value] as myField.ref.value ('(. /. Value) [1]', 'int'), as described in [description] [1] ',' nurturing (10) ' MyField.ref.value ('$ Id ID: = ./Value[1] Return (./Options/Options/Option[@OptionID=$id]/@OptionContent)[1]', 'nvarchar (10)) Apply [myname = 'Fields'] to MyField (referee)  
in the form [selectedDescription @myTable c cross] .myxml.nodes

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -