查阅了MSDN,其实很简单

sp_xml_preparedocument
hdoc 
OUTPUT
[ , xmltext ]
[ , xpath_namespaces ] 
 
You can specify ns using the third parameter.
 

declare @MailContent as nvarchar(max)
select @MailContent=MessageBody from MailStorer where ID=2

--print @MailContent

DECLARE @XmlHandler int
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @XmlHandler OUTPUT, @MailContent,'<ns0:RN_4C1_OUT xmlns:ns0="
http://_4C1_InventoryHold_Intel.MailMessage"/>'

SELECT  '4C1 Inventory Hold On/Off' as Header,*
FROM       OPENXML (@XmlHandler, '/ns0:RN_4C1_OUT/InventoryLine',1)
with
(
    Status nvarchar(50) 'Status',
    Date nvarchar(50) 'DocDate',
    IDocNo nvarchar(50) 'IDocNo',
    SKU nvarchar(50) 'SKU',
    Quantity nvarchar(50) 'Qty',
    RequestBy nvarchar(50) 'RequestBy'
)

-- 清除xml文件句柄,释放内存
exec sp_xml_removedocument @XmlHandler

相关文章:

  • 2021-09-13
  • 2022-12-23
  • 2022-01-07
  • 2021-05-26
  • 2021-05-29
  • 2022-03-01
  • 2022-01-16
猜你喜欢
  • 2021-05-16
  • 2021-11-14
  • 2021-06-09
  • 2021-11-15
  • 2021-07-05
  • 2022-02-08
  • 2021-12-19
相关资源
相似解决方案