Syntax


Here is the syntax for the FOR XML mode expression:

 FOR XML mode [, XMLDATA][, ELEMENTS][, BINARY BASE64] 

The additional parameters are defined as follows :

  • mode . Specifies the XML mode, which can be one of three possibilities

    • RAW. Transforms each row in the result set into an XML element with a generic identifier <row /> as the element tag.

    • AUTO. Returns results in a simple XML tree. Each table in the FROM clause, with at least one column listed in the SELECT clause, is represented as an XML element.The columns listed in the SELECT clause become element attributes.

    • EXPLICIT. Specifies that there is an explicit definition for the shape of the resulting XML. In this mode, queries must be written a specific way so that additional information about the desired nesting is explicitly specified.

  • XMLDATA . A data schema should be returned and prepended to the document.

  • ELEMENTS . This changes the returned document from being attribute-centric to element-centric . In other words, database columns are mapped to child elements instead of to attributes. This option can only be used in AUTO mode.

  • BINARY BASE64 . Specifies that all returned binary data must be in base64 encoding. In RAW and EXPLICIT modes, this parameter must be specified for binary data. In AUTO mode, a reference to the data is always returned.

Binary base64 encoding applies to any data stored in SQL Server that must be treated as a data stream. In our situation (for this text), this is usually graphic data of some type such as the Photo column of the Employees table (refer to Appendix A), which contains a photo of the employee. JPEG and GIF images are other examples of binary data.



XML and SQL Server 2000
XML and SQL Server 2000
ISBN: 0735711127
EAN: 2147483647
Year: 2005
Pages: 104
Authors: John Griffin

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net