SQL Server and XML Integration (2)

Source: Internet
Author: User
Tags base64 sql xmlns
Server|xml Optional Element

The example allows us to learn more about the internal mechanism of the various settings, and we'll take a closer look at the optional element xmldata for the XML statement below.

If you set this option, the Xml-data schema will be included in the result set. The following is an SQL statement:
SET ROWCOUNT 3
SELECT Orders.OrderID, Orders.orderdate, ProductID
From Orders, [order Details]
WHERE Orders.OrderID = [Order Details]. OrderID
ORDER BY Orders.OrderID
For XML AUTO, XMLDATA

The above SQL statement produces the following results:
<schema name= "Schema2" xmlns= "Urn:schemas-microsoft-com:xml-data" xmlns:dt= "urn:schemas-microsoft-com": Datatypes ">
<elementtype name= "Orders" content= "eltonly" model= "closed" order= "many" ><element type= "order_x0020_" Details "maxoccurs=" * "/&GT;

ELEMENTS
The elements option indicates that each data column is returned as a child element rather than as a property. If you use Auto mode, you can use this option only.

BINARY BASE64
Use this option to indicate that you want to represent binary data in the Base64 encoding format.

There is more to the use of XML clauses, you'd better refer to the SQL online books.
Online Guide
The SQL Server online book describes the use of FOR XML clauses. It also mentions a number of limitations to be aware of when using this clause. For example, a FOR XML phrase cannot be combined with a view definition or a COMPUTE BY clause. You may wish to refer to the documentation for more details.

This article is just a simple description of the FOR XML clause, and here's a reminder that this is just a bit of XML integration with SQL Server, and other issues include IIS OpenXML functions and template files. It looks like this, and every pore in SQL Server is dripping with XML.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.