﻿<?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 / T-SQL (SS2K5)  / Delete specific node from XML column / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 26 May 2013 01:04:04 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Delete specific node from XML column</title><link>http://www.sqlservercentral.com/Forums/Topic1410644-338-1.aspx</link><description>[quote][b]thbaig1 (1/23/2013)[/b][hr]can I DELETE DATA FROM tblQuantityP.ProductId in a way IF parent TABLE has NOT record against it ?e.g. Prod1 with ProductId 1 removed from tblProduct, can I DELETE ONly ProductId 1 FROM ALL occurance IN tblQuantityP.ProductId?[/quote] Something like this ? [code="sql"]delete p from tblQuantityP Where exists (select 2 from tblProduct t where t.ProductId = p.ProductId and p.ProductId = 1)[/code]</description><pubDate>Thu, 24 Jan 2013 01:00:37 GMT</pubDate><dc:creator>Bhuvnesh</dc:creator></item><item><title>Delete specific node from XML column</title><link>http://www.sqlservercentral.com/Forums/Topic1410644-338-1.aspx</link><description>TABLE tblProductProductId int Productname varchar(20)TABLE tblQuantityPQuantityPIdQuantity intPrice intProductId XMLDATA IN tblProductProductId  ProductName1			Prod12			Prod23			Prod3	4			Prod45			Prod56			Prod6DATA IN tblQuantityPQuantityPId Quantity	Price	ProductId	1				12		12		&amp;lt;itemids&amp;gt;  &amp;lt;itemid&amp;gt;1&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;2&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;3&amp;lt;/itemid&amp;gt;&amp;lt;/itemids&amp;gt;2				11		21		&amp;lt;itemids&amp;gt;  &amp;lt;itemid&amp;gt;2&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;5&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;6&amp;lt;/itemid&amp;gt;&amp;lt;/itemids&amp;gt;3				11		11		&amp;lt;itemids&amp;gt;  &amp;lt;itemid&amp;gt;222&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;5&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;6&amp;lt;/itemid&amp;gt;&amp;lt;/itemids&amp;gt;4				134		11		&amp;lt;itemids&amp;gt;  &amp;lt;itemid&amp;gt;2&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;5&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;6&amp;lt;/itemid&amp;gt;&amp;lt;/itemids&amp;gt;5				112		11		&amp;lt;itemids&amp;gt;  &amp;lt;itemid&amp;gt;2&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;5&amp;lt;/itemid&amp;gt;  &amp;lt;itemid&amp;gt;6&amp;lt;/itemid&amp;gt;&amp;lt;/itemids&amp;gt;Now I can JOIN XML COLUMN TO mother TABLE TO GET DATA AS following . (suggest IF SOME more optimized way: Not real question)SELECT  qp.QuantityPId ,        Prod.ProductId ,        Prod.ProductNameFROM    dbo.tblQuantityP qp        CROSS APPLY ProductId.nodes('itemids/itemid') AS xmlitems ( itemid )        JOIN dbo.tblProduct Prod ON Prod.ProductId = xmlitems.ProductId.value('.',                                                              'int');                                                              [b]My Question[/b] is can I DELETE DATA FROM tblQuantityP.ProductId in a way IF parent TABLE has NOT record against it ?e.g. Prod1 with ProductId 1 removed from tblProduct, can I DELETE ONly ProductId 1 FROM ALL occurance IN tblQuantityP.ProductId?</description><pubDate>Wed, 23 Jan 2013 08:55:36 GMT</pubDate><dc:creator>thbaig1</dc:creator></item></channel></rss>