Some Opinions on SQL Server 2000's XML support

Source: Internet
Author: User
Some Opinions on SQL Server 2000's XML support
This article mainly discusses similar statements of "select Field 1, Field 2,..., field N from table or multi-table joint query where condition for XML auto ".

When I used the preceding statements to generate XML data, I found some rules for SQL Server 2000 to generate XML data. I felt that the requirements were too harsh, we can also see that Microsoft's early support for XML is insufficient. now I will write my experiences to you. I hope you can point out the shortcomings.
XML allows you to easily describe tree-type data, which is not enough for relational data. Therefore, converting relational data to tree-structured data is troublesome. Fortunately, SQL Server 2000 provides the conversion interface in this regard. However, if you want to convert it, it is also possible.

Prerequisites: SQL Server 2000 already has a basic table (View) that describes the tree structure data. [for example, the tree structure information of the faculty and class in the university, the school information is a table, a department information table, a class information table, and a primary-foreign key relationship has been established between the tables.]

1. The positions of fields to be displayed are ordered. To correctly display the tree structure of the Department and Department classes, write the SQL statement for conversion:
Select School, department, class from school, department, class where condition for XML auto
2. do not perform any operations or processing on the displayed fields as far as possible, because this will damage the data of the basic table (View) as a certain level of data conventions.
For example, after performing some operations and processing on the "System" Field of the "select courtyard, department, class from courtyard, department, and class where condition for XML auto" statement,
SQL Server 2000 cannot correctly describe the layer of data generated by the "System" field after the XML data is generated. Generally,
SQL Server 2000 automatically adds the "System" field to the "school" or "class" layer. In this way, we cannot get the expected results.
3. When performing multi-table joint queries, do not have subqueries, because even if you use subqueries, they are useless,
The conversion statement "select Field 1, Field 2,..., field N from table or multi-table joint query where condition for XML auto" only recognizes basic tables and views. Don't think about using subqueries to implement some complex functions.

The preceding example uses "select Field 1, Field 2 ,..., when the field N from table or multi-table joint query where condition for XML auto "statement, some of the experiences are gibberish.
 

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.