title: SQL Server : extract value from XML column
body: <p>I have a <code>xml</code> column <code>Formdata</code> in a table <code>pt_formdata</code> in SQL Server. This is how my xml looks like:</p>
  
  <pre><code>&lt;?csps doctype="dataset" version="1.0.0"?&gt; 
  &lt;csps:root formtype="AFTeleIntake" guid="ecde2347-ae24-4bd0-a4bd-60e11ca38ed9" xmlns:csps="http://tempuri.org/AFTeleIntake.xsd"&gt;
   &lt;Questions&gt;
    &lt;row&gt;
     &lt;ReferringProvider&gt;Abc&lt;/ReferringProvider&gt; 
     &lt;PrimaryCareProvider&gt;Bcd&lt;/PrimaryCareProvider&gt; 
     &lt;TelephoneContactDate&gt;07-Nov-2013&lt;/TelephoneContactDate&gt; 
     &lt;AFType&gt;type1&lt;/AFType&gt; 
    &lt;/row&gt;
   &lt;/Questions&gt;
  &lt;/csps:root&gt;
  </code></pre>
  
  <p>I want to create a SQL query to fetch <code>AFType</code> from this xml column. I'm pretty new to SQL Server, and I have tried lots of functions. </p>
  
  <p>For example:</p>
  
  <pre><code>SELECT 
     PT_FormData.Formdata.query('declare namespace x="http://tempuri.org/AFTeleIntake.xsd";
        (/x:csps/x:Questions/x:row/x:AFType)') AS Description 
  FROM database.[dbo].[PT_FormData]
  </code></pre>
  
  <p>but the output column empty.How can I get around what I want? </p>
  
  <p>Any help will be appreciated</p>
  
  <p>Thanks
  Tina</p>