title: SQL Server - XML Validation: Invalid simple type value
body: <p>I'm trying to validate an XML input against an XML Schema in SQL Server 2005 and I get an error when validating the e-mail:</p>
  <blockquote>
  <p>Msg 6926, Level 16, State 1, Line 4</p>
  <p>XML Validation: Invalid simple type value: 'john_doe@yahoo.com'. Location: /<em>:xxx[1]/</em>:yyy[1]/*:Email[1]</p>
  </blockquote>
  <p>The email field is defined in the schema as:</p>
  <pre><code> &lt;xsd:simpleType name=&quot;EMailType&quot;&gt;
      &lt;xsd:restriction base=&quot;xsd:string&quot;&gt;
        &lt;xsd:pattern value=&quot;\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*&quot; /&gt;
      &lt;/xsd:restriction&gt;
    &lt;/xsd:simpleType&gt;
  </code></pre>
  <p>Every email address that matches the regexp is considered valid except for something with underscores in it (<code>johnDoe@yahoo.com</code> is OK, <code>john.doe@yahoo.com</code> is OK, but <code>john_doe@yahoo.com</code> is not).</p>
  <p>If I remove the underscore the XML is validated.</p>
  <p>I've tested my regexp (which is the one you can find on MSDN for validating emails) with various tools and they all say it's valid. But not SQL Server.</p>
  <p>Why does it not validate underscores? Is there something special I must do in SQL Server?</p>