|
XML Support in SQL Server started with SQL Server 2000. SQL Server 2000 database engine introduced two interesting XML features: FOR XML and OPENXML() for generating XML documents and querying XML documents.
FOR XML is a rowset aggregation function that can generate an XML document from the results of a SELECT query. FOR XML in SQL Server 2000 is used with AUTO, RAW or EXPLICIT direcives. Each of them provides different level of control over the structure of the XML output.
OPENXML() is used to shred an XML document into a rowset. OPENXML() uses MSXML parser internally through OLE Automation. A typical call to OPENXML() involves a three step process where a call to be made to a system stored procedure to obtaiin a handle to the XML document, do the query and finally release the document handle.
SQL Server 2005 introduced a large number of XML features to the database engine. One of the most significant addition is the new XML native data type. XML data type can be used to store an XML document or fragment. The XML Data type supports a number of methods that can be used to query or modify the XML document stored in it.
XQuery is a W3C recommended specification for reading information from XML Documents. XQuery can be used to read information from XML documents, just like SQL is used to read information from relational tables. XML Data Type supports a limited subset of XQuery specification.
XSD (XML Schema Definition Language) is another specification recommended by W3C for describing and validating XML documents. SQL Server (2005 and later versions) implements XSD support in the form of XML Schema Collections. An XML data type column or variable can be associated with an XML Schema Collection and SQL Server will validate the XML value against the rules defined in the Schema Collection when value is assigned or modified.
SQL Server 2008 introduced further enhancements in the XQuery (new functions, DML enhancements) and XSD (lax validation, union of lists etc) features supported by the previous version.
The goal of this section at beyondrelational.com is to bring enough XML related resources (articles, tutorials, blog posts, training material etc) to the readers to get started and master the XML features supported by SQL Server. This is a humble beginning with some basic XML resources, but we are working hard to bring you a large collection of XML stuff. Contact us with your suggestions and recommendations for including resources that you think are helpful.
|