列舉面向

適用於:SQL ServerAzure SQL DatabaseAzure SQL 受控執行個體Microsoft Fabric 中的 SQL 資料庫

SQL Server 會拒絕含有下列型別的 XML 結構描述:其具有 pattern facet,或其列舉值違反這些 facet。

範例

下列結構描述會被拒絕,因為名為 featured 的列舉值包含大小寫混合的值。 它也會被拒絕,因為此值違反了將值限制為只能使用小寫字母的模式值。

CREATE XML SCHEMA COLLECTION MySampleCollection AS '
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ns" xmlns:ns="http://ns">
    <simpleType name="MyST">
       <restriction base="string">
          <pattern value="[a-z]*"/>
       </restriction>
    </simpleType>

    <simpleType name="MyST2">
       <restriction base="ns:MyST">
           <enumeration value="mYstring"/>
       </restriction>
    </simpleType>
</schema>';
GO