<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Carrington &#187; SQL</title>
	<atom:link href="http://davidcarrington.co.uk/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidcarrington.co.uk</link>
	<description>UK web developer that loves phones</description>
	<lastBuildDate>Wed, 25 Jan 2012 13:53:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SQL Server XQuery and Namespaces</title>
		<link>http://davidcarrington.co.uk/2010/01/sql-server-xquery-and-namespaces/</link>
		<comments>http://davidcarrington.co.uk/2010/01/sql-server-xquery-and-namespaces/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 12:04:46 +0000</pubDate>
		<dc:creator>David Carrington</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[xmlns]]></category>
		<category><![CDATA[XQuery]]></category>

		<guid isPermaLink="false">http://davidcarrington.co.uk/?p=262</guid>
		<description><![CDATA[I just had a frustrating little SQL Server problem earlier today and would like to share the handy solution I found via Experts Exchange. SELECT ResponseXml.value('(//Reference)[1]', 'varchar(50)') FROM Transaction A fairly simple XQuery request of an XML column but annoyingly it didn&#8217;t work, and it turned out to to be because the ResponseXml had an [...]]]></description>
			<content:encoded><![CDATA[<p>I just had a frustrating little SQL Server problem earlier today and would like to share the handy solution I found via Experts Exchange.</p>
<p><code>SELECT ResponseXml.value('(//Reference)[1]', 'varchar(50)')<br />
FROM Transaction</code></p>
<p>A fairly simple XQuery request of an XML column but annoyingly it didn&#8217;t work, and it turned out to to be because the ResponseXml had an unnamed XML namespace, which SQL Server doesn&#8217;t handle too nicely.</p>
<p><code>&lt;Message xmlns="http://www.example.com/"&gt;<br />
  &lt;Reference&gt;123&lt;/Reference&gt;<br />
&lt;/Message&gt;</code></p>
<p>It&#8217;s the xmlns attribute (XML namespace) that causes the problem apparently, and the simplest solution I found was this snippet:</p>
<p><code>SELECT ResponseXml.value('declare default element namespace "http://www.example.com/"; (//Reference)[1]', 'varchar(50)')<br />
FROM Transaction</code></p>
<p>I just had to tell XQuery to use a different default namespace &#8211; a lot simpler than other suggested solutions such as removing the namespace from the XML.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidcarrington.co.uk/2010/01/sql-server-xquery-and-namespaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

