﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 General Discussion  / Update table from XML / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 16 Mar 2010 18:03:58 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Update table from XML</title><link>http://www.sqlservercentral.com/Forums/Topic808516-149-1.aspx</link><description>[code="sql"]declare @xml xmlset @xml = '&amp;lt;items&amp;gt;&amp;lt;item id="1" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;item id="2" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;item id="3" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;/items&amp;gt;'Update MyTableSet ISDELETED = B.ISDELETEDFrom MyTable AInner Join 	(	select xmlcol.value('@id','int') as ID,	xmlcol.value ('@ISDELETED', 'char(1)') as IsDeleted	from @xml.nodes ('/items/item') tbl (xmlcol)	) B on B.ID = A.ITEMID[/code]</description><pubDate>Thu, 29 Oct 2009 23:38:53 GMT</pubDate><dc:creator>Atif Sheikh</dc:creator></item><item><title>RE: Update table from XML</title><link>http://www.sqlservercentral.com/Forums/Topic808516-149-1.aspx</link><description>You can use the noeds and value XML methods together in order to get the information in tabular format.  If you’ll do it in a CTE, you’ll get the results and you’ll be able to use it as if it was a table.  Here is the part that creates the CTE.  From here it is just a regular update statement that uses 2 tables.[code]declare @xml xmlset @xml = '&amp;lt;items&amp;gt;&amp;lt;item id="1" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;item id="2" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;item id="3" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;/items&amp;gt;';with MyCTE as (	select xmlcol.value('@id','int') as ID,	xmlcol.value ('@ISDELETED', 'char(1)') as IsDeleted	from @xml.nodes ('/items/item') tbl (xmlcol))select * from MyCTE[/code]Adi </description><pubDate>Mon, 26 Oct 2009 10:09:29 GMT</pubDate><dc:creator>Adi Cohn-120898</dc:creator></item><item><title>Update table from XML</title><link>http://www.sqlservercentral.com/Forums/Topic808516-149-1.aspx</link><description>Hello,I want to update a table from xml that is supplied. My XML&amp;lt;items&amp;gt;&amp;lt;item id="1" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;item id="2" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;item id="3" ISDELETED="D"&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;/items&amp;gt;I need to update isdeleted field depending on the ID. Table name TBL_NEWSplease provide me the stored proc</description><pubDate>Mon, 26 Oct 2009 01:38:49 GMT</pubDate><dc:creator>babitheboy</dc:creator></item></channel></rss>