XML data modification Language for SQL Server 2005

Source: Internet
Author: User
Tags expression insert sql xquery

As an extension of the XQuery language, XML DML provides greater flexibility for XML data operations rather than simply querying the XML data. With XML DML, users can insert, update, and delete node contents in XML as they do with relational tables. XML DML needs to be invoked through the Modify method of the XML data type.

1. Insert

Inserts are used to insert a child node or sibling node of a node that is identified by the Expression1 as one or more nodes of the Expression2 identity. The syntax format is as follows:

insert
   Expression1 (
         {as first | as last} into | after | before
                  Expression2
        )

Expression1 and Expression2

Identifies one or more nodes to insert. It can be a constant XML instance, or it can be an XQuery expression. The expression can draw a node, a text node, or a set of ordered nodes, but it cannot solve the root node. If the expression results in a value or a set of values, the values are inserted as a single text node, separated by a space between the values. If multiple nodes are specified as constants, the nodes are enclosed in parentheses and separated by commas. However, you cannot insert a heterogeneous sequence (such as a group element, attribute, or value). If Expression1 an empty sequence, the insert operation does not occur and no errors are returned.

Into

Expression1 The identified node is inserted as a child of the node identified by Expression2. If a node in Expression2 already has one or more child nodes, you must specify the desired new node add location using as a or last.

After

The Expression1-identified node is inserted directly behind it as a sibling of the node identified by Expression2, and the After keyword cannot be used to insert the property.

Before

The Expression1-identified node is inserted directly in front of the sibling node of the Expression2-identified node, and the Before keyword cannot be used for insert properties.



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.