How to use AXSD in SQL Server?

In SQL Server, you can use the XML data type and map it to relational columns using the AXSD schema.

Mapping Between XML and Relational Storage Using Annotated Schema (AXSD), XML is decomposed into columns in one or more tables. This preserves the reliability of the data at the relational level. As a result, the hierarchical structure is preserved, although the order among the elements is ignored. A schema cannot be recursive.

from MSDN

However, I cannot find documentation on how to do this - or even a good page on AXSD.

Does anyone have good AXSD info. it seems very appropriate what I want to do (temporarily use XML until I can switch to something like nHibernate, but still allow the viewing of the columns of some permanent data fields.

+3
source share
1 answer

This seems like a way to do this and this is also useful .

And a free book too !

tip: search for "annotated xsd schemass", not AXSD!

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
  <xsd:element name="Employee" sql:relation="Employees" >
   <xsd:complexType>
     <xsd:sequence>
        <xsd:element name="FName"  
                     sql:field="FirstName" 
                     type="xsd:string" /> 
        <xsd:element name="LName"  
                     sql:field="LastName"  
                     type="xsd:string" />
     </xsd:sequence>
        <xsd:attribute name="EmpID" 
                       sql:field="EmployeeID" 
                       type="xsd:integer" />
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
+3
source

Source: https://habr.com/ru/post/1717037/


All Articles