Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Updating XML attributes using a lookup table
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 12/18/2012 :  15:40:46  Show Profile  Reply with Quote

I want to update all the attribute values inside all the nodes (name) that matches a look up table (lookup table has Name and ID) with the Id of the look up table.

Sample XML:
<SECTION NAME="Classes">
<ITEM NAME="1309" />
<ITEM NAME="1335" />
<ITEM NAME="1375" />
<ITEM NAME="1387" />
<ITEM NAME="1537" />
<ITEM NAME="1539" />

Please help me with this.


Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/18/2012 :  16:13:43  Show Profile  Reply with Quote
You can conceivably use the modify method in XQuery, (see here and the links on that page. But the modify method is rather limited and inflexible in my experience unless you are trying to do simple modifications. If your XML is as simple as you have shown in the example, it is perhaps easier to shred the XML into a relational (virtual) table, make the changes you need to and reconstitute the XML.

If you can post the DDL, sample data and desired output, people on the forum should be able to use the approach I outlined above, or another approach. If you need help in posting, take a look at this page
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000