SQL Server includes improvements to the legacy FOR XML clause. One improvement is tighter integration with the new xml data type, including options to generate native xml-typed results. FOR XML results can be assigned to variables of the xml data type, with additional support for nesting FOR XML queries, an improvement on the SQL Server 2000 FOR XML clauses, which were limited only to the top level of a SELECT statement. The FOR XML PATH mode, also carried over from SQL Server 2005, is an improvement over the legacy FOR XML EXPLICIT mode. With builtin support for XPath-style expressions, FOR XML PATH makes generating XML in explicit structures
much easier than was possible in SQL Server 2000.
The FOR XML RAW mode has also been improved with additional features, including the ability to rename the default row element name, the ability to explicitly specify the root node, and the ability to retrieve your data in an element-centric format. The FOR XML AUTO and FOR XML EXPLICIT modes have also been improved with additional options and settings.
While some options have been deprecated, several additional options have been added to the FOR XML clauses since the SQL Server 2000 version, including the ELEMENTS XSINIL option, which generates elements for NULLs in the result set, and XMLSCHEMA, which generates an inline XML Schema Definition (XSD) in your XML result. T
much easier than was possible in SQL Server 2000.
The FOR XML RAW mode has also been improved with additional features, including the ability to rename the default row element name, the ability to explicitly specify the root node, and the ability to retrieve your data in an element-centric format. The FOR XML AUTO and FOR XML EXPLICIT modes have also been improved with additional options and settings.
While some options have been deprecated, several additional options have been added to the FOR XML clauses since the SQL Server 2000 version, including the ELEMENTS XSINIL option, which generates elements for NULLs in the result set, and XMLSCHEMA, which generates an inline XML Schema Definition (XSD) in your XML result. T