SQL check XML node exists via a variable, add & delete -
I'm exploring a way to check whether NODE exists in an XML data type using any MODQL 2012 I want to see the varchar in a stored procedure as node, I have tried something like the bottom, but it does not appear to work, what I want to do is "null" Var2 (SP) As passed in varchar), and if it exists, So if it does not exist, then insert it into the root of all the nodes found in all the examples are hardcodes, which works. Code as a variable with node: declared @node varchar (255) declared @ x xml set @ annode = 'var2' set @ x = ' & Lt; Root & gt; & Lt; Var1 & gt; 0 & lt; / Var1 & gt; & Lt; Var2 & gt; 123 & lt; / Var2 & gt; & Lt; var3 & gt; 1000 & lt; / Var3 & gt; & Lt; var4 & gt; 989 & lt; / var4 & gt; & Lt; / Root & gt; 'Code with hardcod node: @ x.exist (' //. [Node (=) (select "variable: variable (" node ")] '' - always gives false returns ...