December 29, 2010 at 4:29 am
Hi all,
Firstly merry Christmas to all.
I've got a problem, where I am trying to read from XML, I'm running the code below and it all works fine.
FROM @XMLInput.nodes('/data/struct/var[@name="Tier1"]/struct/var[@name="Tier2"]/struct/var') AS i(item)
However, the node Tier2 can be different, so I need to substitute it with a variable, but I cant seem to figure out how I can acheive this.
So I want it to look something like;
FROM @XMLInput.nodes('/data/struct/var[@name="Tier1"]/struct/var[@name="@VariableA"]/struct/var') AS i(item)
I've done some reading up on 'sql:variable' but I cant seem to get the syntax right, any one any idea's on how I can do this?
Thanks,
Nic
December 29, 2010 at 5:07 am
Hi all,
Managed to figure it out, I basically did the following;
@XMLInput.nodes('/data/struct/var[@name="Tier1"]/struct/var[@name=sql:variable("@VariableA")]/struct/var')
Just thought I would share the knowledge incase anyone else has a similar issue.
Thanks,
Nic
December 29, 2010 at 8:18 am
Nic,
Very interesting. Thanks for posting your solution - I've learned something out of this!
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply