﻿<?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 2008 / T-SQL (SS2K8)  / XQuery: Get the value only, and not the child node values / 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>Wed, 22 May 2013 09:45:30 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: XQuery: Get the value only, and not the child node values</title><link>http://www.sqlservercentral.com/Forums/Topic1382462-392-1.aspx</link><description>LIVING AND LEARNING!!!!!!!   :-D</description><pubDate>Thu, 08 Nov 2012 09:26:26 GMT</pubDate><dc:creator>carlosaamaral</dc:creator></item><item><title>RE: XQuery: Get the value only, and not the child node values</title><link>http://www.sqlservercentral.com/Forums/Topic1382462-392-1.aspx</link><description>Use CROSS APPLY[code="sql"]DECLARE @xml XML ='&amp;lt;ROOT&amp;gt;&amp;lt;SPECIALNEEDS&amp;gt;    INCLUDE    &amp;lt;NEED&amp;gt;        BLIND    &amp;lt;/NEED&amp;gt;    &amp;lt;NEED&amp;gt;        BRAILLE AUDIO    &amp;lt;/NEED&amp;gt;&amp;lt;/SPECIALNEEDS&amp;gt;&amp;lt;/ROOT&amp;gt;'SELECT @xml AS xmlColINTO #temptableSELECT   TD.D.value('./text()[1]','Varchar(400)') FROM     #temptableCROSS APPLY xmlCol.nodes('/ROOT/SPECIALNEEDS') AS TD(D)[/code]</description><pubDate>Thu, 08 Nov 2012 08:41:24 GMT</pubDate><dc:creator>Mark-101232</dc:creator></item><item><title>RE: XQuery: Get the value only, and not the child node values</title><link>http://www.sqlservercentral.com/Forums/Topic1382462-392-1.aspx</link><description>Thanks Eugene, That was really helpful.Just because I am anal about these things ;-)How would you write the select statement if the data was in a #temptable with a column of type XML</description><pubDate>Thu, 08 Nov 2012 07:58:09 GMT</pubDate><dc:creator>aaron.reese</dc:creator></item><item><title>RE: XQuery: Get the value only, and not the child node values</title><link>http://www.sqlservercentral.com/Forums/Topic1382462-392-1.aspx</link><description>[code="sql"]DECLARE @xml XML ='&amp;lt;ROOT&amp;gt;&amp;lt;SPECIALNEEDS&amp;gt;    INCLUDE    &amp;lt;NEED&amp;gt;        BLIND    &amp;lt;/NEED&amp;gt;    &amp;lt;NEED&amp;gt;        BRAILLE AUDIO    &amp;lt;/NEED&amp;gt;&amp;lt;/SPECIALNEEDS&amp;gt;&amp;lt;/ROOT&amp;gt;'SELECT   TD.D.value('./text()[1]','Varchar(400)') FROM     @xml.nodes('/ROOT/SPECIALNEEDS') AS TD(D)[/code]Please note the whitespace preserved on the left of INCLUDE, as it's part of the node text. You can LTRIM it or make sure you XML formed appropriately eg:[code="sql"]'&amp;lt;ROOT&amp;gt;&amp;lt;SPECIALNEEDS&amp;gt;INCLUDE    &amp;lt;NEED&amp;gt;        BLIND    &amp;lt;/NEED&amp;gt;    &amp;lt;NEED&amp;gt;        BRAILLE AUDIO    &amp;lt;/NEED&amp;gt;&amp;lt;/SPECIALNEEDS&amp;gt;&amp;lt;/ROOT&amp;gt;'[/code]</description><pubDate>Thu, 08 Nov 2012 06:44:59 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>XQuery: Get the value only, and not the child node values</title><link>http://www.sqlservercentral.com/Forums/Topic1382462-392-1.aspx</link><description>Hi Guys,If I have the following XML[code="sql"]&amp;lt;ROOT&amp;gt;&amp;lt;SPECIALNEEDS&amp;gt;	INCLUDE	&amp;lt;NEED&amp;gt;		BLIND	&amp;lt;/NEED&amp;gt;	&amp;lt;NEED&amp;gt;		BRAILLE AUDIO	&amp;lt;/NEED&amp;gt;&amp;lt;/SPECIALNEEDS&amp;gt;&amp;lt;/ROOT&amp;gt;[/code]How do I get the value "INCLUDE" only.xmltext.value('(ROOT/SPECIALNEEDS)[1]', nvarchar(max)) is giving me all the value contents (Include  Blind  Braille Audio) </description><pubDate>Thu, 08 Nov 2012 06:36:48 GMT</pubDate><dc:creator>aaron.reese</dc:creator></item></channel></rss>