I try to validate XML input in an XML schema in SQL Server 2005, and I get an error when checking email:
Msg 6926, Level 16, State 1, Line 4
XML Validation: Invalid simple type value: ' john_doe@yahoo.com '. Location: /: xxx [1] /: yyy [1] / *: Email [1]
The email field is defined in the schema as:
<xsd:simpleType name="EMailType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" /> </xsd:restriction> </xsd:simpleType>
Each email address that matches the regular expression is considered valid, except for something with an underscore in it ( johnDoe@yahoo.com OK, john.doe@yahoo.com is OK, but john_doe@yahoo.com not).
If I delete the underscore, XML is checked.
I checked my regex (which can be found on MSDN for checking emails) using various tools, and they all say that it is valid. But not SQL Server.
Why does this not confirm underscores? Is there anything special about SQL Server?
source share