zoukankan      html  css  js  c++  java
  • (4.41)sql server如何把xml转换成表格数据?

     废话不多说,直接上代码

    declare @temp xml;
    set @temp='<root><note>
    <to>George</to>
    <from>John</from>
    <heading>Reminder</heading>
    <body>Dont forget the meeting!</body>
    </note>
    <note>
    <to>tom</to>
    <from>cat</from>
    <heading>test</heading>
    <body>test 123</body>
    </note>
    </root>';
    select [to]=o.value('to[1]','nvarchar(500)'),
                   [from]=o.value('from[1]','nvarchar(500)'),
                   [heading]=o.value('heading[1]','nvarchar(500)'),
                   [body]=o.value('body[1]','nvarchar(500)')               
                 from (select x=@temp) a
                 cross apply x.nodes('root/note') x(o) 

      

  • 相关阅读:
    053-49
    053-3
    053-204
    053-491
    053-205
    053-57
    053-149
    053-47
    053-150
    回答2
  • 原文地址:https://www.cnblogs.com/gered/p/12720695.html
Copyright © 2011-2022 走看看