doubt in insertion syntax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sharravananap
    New Member
    • May 2008
    • 1

    doubt in insertion syntax

    INSERT #Orders (OrderID, CustomerID, EmployeeID, OrderDate)
    SELECT OrderID, CustomerID, EmployeeID, OrderDate
    FROM
    OPENXML(@iTree, 'Order', 1)
    WITH ( OrderID INTEGER,
    EmployeeID INTEGER,
    OrderDate DATETIME,
    CustomerID nCHAR(5))

    -- Insert Order Details Record
    INSERT #OrderDetails
    SELECT * FROM
    OPENXML(@iTree, 'Order/Items/Item', 1)
    WITH ( OrderID INTEGER '../../@OrderID',
    ProductID INTEGER,
    Qty INTEGER,
    UnitPrice MONEY,
    Discount REAL 'Discount')

    in the above syntax for inserting xml data into sql table, in the fourth line syntax OPENXML(@iTree, 'Order', 1)

    here in the above why 'Order' is placed there, i dont know for what purpose it is placed, please clarify this as soon as possible
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    The OPENXML function accepts three arguments, the first two of which are required. ....
    The second argument is an XPATH (XML Path Language) pattern used to identify the nodes in the XML document.

    From:




    So basically, you're pointing to the Order nodes.

    Comment

    Working...