Sp_xml_preparedocument process XML documents

Source: Internet
Author: User

In projects, data submission from the master and slave tables is often encountered. It is much easier to use sp_xml_preparedocument to input XML competing SQL statements.

Declare @ XML varchar (1024)
Set @ xml = '<root> <code id = "030001"> <point id = "01"/> <point id = "02"/> </code> </ root>'
Declare @ hdoc int
Exec sp_xml_preparedocument @ hdoc out, @ XML
Select * from
Openxml (@ hdoc, '/root/code/point', 2)
With
(
Itemcode varchar (36) '../@ id ',
Point varchar (36) '@ id'
) As
-- The result set a contains information about the master and slave tables.
-- Insert into tablea select * from
Exec sp_xml_removedocument @ hdoc

For a detailed introduction to this stored procedure, see here http://www.yesky.com/imagesnew/software/tsql/ts_sp_xml_267o.htm
For more information about openxml, click here http://www.itcankao.cn/ShowTopic/Topic_21_Art_677.html
On the official msdn website, I cannot open it here. If you prefer to visit the official website, Google it.

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.