Inserting XML data directly into SQL Server database

Source: Internet
Author: User

Stored procedures:

ALTER proc [Ali].[ins_ frozen Amount Table]@xmldoc varchar(Max),@userGid varchar( -) asDeclare @idoc intexecsp_xml_preparedocument@idocOutput@xmldocInsert  intoali.user frozen Amount TableSelect newid(),@userGid,*,getdate() fromOpenXML@idoc,'/alipay_user_account_freeze_get_response/freeze_items/account_freeze',2)   with(Freeze_amountdecimal( -,2), Freeze_namevarchar( -), Freeze_typevarchar( -))  execSp_xml_removedocument@idoc--frees memory because the callsp_xml_preparedocument, it consumes one-eighth of the total memory of SQL Server, so use it to immediately eliminate

Because it is possible to return a "invalid character found in text content" error when executing sp_xml_preparedocument (because a Chinese character exists in XML), the header information needs to be added to the XML, and if the XML is varchar, the <?xml Version= "1.0" encoding= "gb2312"?>, or simply change the XML type to nvarchar, there will be no error.

Inserting XML data directly into SQL Server database

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.