SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

satty.fl
Starting Member

1 Posts

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


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" />
</SECTION>

Please help me with this.

Thanks

sunitabeck
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  
 New 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.03 seconds. Powered By: Snitz Forums 2000