August 31, 2011 at 1:19 pm
I want to pass veriable for Node name in XQuery is it possible to do something like this??
DECLARE @Email VARCHAR(50) = a@b.com', @NodeName VARCHAR(50) = 'Email'
DECLARE @NodeXml XML
SELECT @NodeXml = '''<'+ @NodeName+ '></' + @NodeName +'> '''
SET @NodeXml.modify
(
'insert text{sql:variable("@Email")} as first into
sql:variable("@NodeName")'
)
SELECT @NodeXml
September 13, 2011 at 5:02 am
Like this?
DECLARE @Email VARCHAR(50) = 'a@b.com', @NodeName VARCHAR(50) = 'Email'
DECLARE @NodeXml XML
SELECT @NodeXml = '<'+ @NodeName+ '></' + @NodeName +'>'
SET @NodeXml.modify
(
'insert text{sql:variable("@Email")} into /*[local-name()=sql:variable("@NodeName")][1]'
)
SELECT @NodeXml
Jacob Sebastian's blog http://beyondrelational.com/blogs/jacob/archive/2008/08/26/xquery-lab-24-reading-value-of-an-element-specified-by-a-variable.aspx is a treasure trove of XQuery tips
September 13, 2011 at 7:32 am
Thanks Jacob
This works for me
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply