<i id='kuhmR'><tr id='kuhmR'><dt id='kuhmR'><q id='kuhmR'><span id='kuhmR'><b id='kuhmR'><form id='kuhmR'><ins id='kuhmR'></ins><ul id='kuhmR'></ul><sub id='kuhmR'></sub></form><legend id='kuhmR'></legend><bdo id='kuhmR'><pre id='kuhmR'><center id='kuhmR'></center></pre></bdo></b><th id='kuhmR'></th></span></q></dt></tr></i><div id='kuhmR'><tfoot id='kuhmR'></tfoot><dl id='kuhmR'><fieldset id='kuhmR'></fieldset></dl></div>

    1. <small id='kuhmR'></small><noframes id='kuhmR'>

        <bdo id='kuhmR'></bdo><ul id='kuhmR'></ul>

      <tfoot id='kuhmR'></tfoot>
      <legend id='kuhmR'><style id='kuhmR'><dir id='kuhmR'><q id='kuhmR'></q></dir></style></legend>

        在sql server中解析xml

        时间:2023-06-07
          <bdo id='IvDvy'></bdo><ul id='IvDvy'></ul>

            <tbody id='IvDvy'></tbody>
              <i id='IvDvy'><tr id='IvDvy'><dt id='IvDvy'><q id='IvDvy'><span id='IvDvy'><b id='IvDvy'><form id='IvDvy'><ins id='IvDvy'></ins><ul id='IvDvy'></ul><sub id='IvDvy'></sub></form><legend id='IvDvy'></legend><bdo id='IvDvy'><pre id='IvDvy'><center id='IvDvy'></center></pre></bdo></b><th id='IvDvy'></th></span></q></dt></tr></i><div id='IvDvy'><tfoot id='IvDvy'></tfoot><dl id='IvDvy'><fieldset id='IvDvy'></fieldset></dl></div>
              <legend id='IvDvy'><style id='IvDvy'><dir id='IvDvy'><q id='IvDvy'></q></dir></style></legend>
              1. <small id='IvDvy'></small><noframes id='IvDvy'>

              2. <tfoot id='IvDvy'></tfoot>

                  本文介绍了在sql server中解析xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个包含 xml 的 ntext 类型列的表.我已尝试应用许多示例,说明如何从特定节点的 xml 中提取公司名称的值,但仍然出现语法错误.下面是我所做的,除了用我的 select 语句替换了实际的 xml 输出

                  I have a table with an ntext type column that holds xml. I have tried to apply many examples of how to pull the value for the company's name from the xml for a particular node, but continue to get a syntax error. Below is what I've done, except substituted my select statement for the actual xml output

                  DECLARE @companyxml xml
                  
                      SET @companyxml = 
                      '<Home>
                        <slideshowImage1>1105</slideshowImage1>
                        <slideshowImage2>1106</slideshowImage2>
                        <slideshowImage3>1107</slideshowImage3>
                        <slideshowImage4>1108</slideshowImage4>
                        <slideshowImage5>1109</slideshowImage5>
                        <bottomNavImg1>1155</bottomNavImg1>
                        <bottomNavImg2>1156</bottomNavImg2>
                        <bottomNavImg3>1157</bottomNavImg3>
                        <pageTitle>Acme Capital Management |Homepage</pageTitle>
                        <metaKeywords><![CDATA[]]></metaKeywords>
                        <metaDescription><![CDATA[]]></metaDescription>
                        <companyName>Acme Capital Management</companyName>
                        <logoImg>1110</logoImg>
                        <pageHeader></pageHeader>
                      </Home>'
                  
                  SELECT c.value ('companyName','varchar(1000)') AS companyname 
                  FROM @companyxml.nodes('/Home') AS c
                  

                  出于某种原因,select c.value 语句有一个我无法弄清楚的语法问题.在 SSMS 中悬停时,它说找不到列c"或用户定义的函数或聚合c.value",或者名称不明确.'

                  For some reason, the select c.value statement has a syntax problem that I can't figure out. On hover in SSMS, it says 'cannot find either column "c" or the user-defined function or aggregate "c.value", or the name is ambiguous.'

                  对语法的任何帮助将不胜感激.

                  Any help on the syntax would be greatly appreciated.

                  推荐答案

                  试试这个

                   DECLARE @companyxml xml
                  
                  SET @companyxml = 
                  '<Home>
                    <slideshowImage1>1105</slideshowImage1>
                    <slideshowImage2>1106</slideshowImage2>
                    <slideshowImage3>1107</slideshowImage3>
                    <slideshowImage4>1108</slideshowImage4>
                    <slideshowImage5>1109</slideshowImage5>
                    <bottomNavImg1>1155</bottomNavImg1>
                    <bottomNavImg2>1156</bottomNavImg2>
                    <bottomNavImg3>1157</bottomNavImg3>
                    <pageTitle>Acme Capital Management Homepage</pageTitle>
                    <metaKeywords>CDATA</metaKeywords>
                    <metaDescription>CDATA</metaDescription>
                    <companyName>Acme Capital Management</companyName>
                    <logoImg>1110</logoImg>
                    <pageHeader></pageHeader>
                  </Home>'
                  
                  
                  DECLARE @Result AS varchar(50)
                  
                  SET @result = @companyxml.value('(/Home/companyName/text())[1]','varchar(50)')
                  
                  SELECT @result
                  

                  这篇关于在sql server中解析xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:带有未声明前缀的 SQL Server Xml 查询 下一篇:如何将 XML 文件及其列名导入 SQL 表?

                  相关文章

                  最新文章

                  <small id='To9NH'></small><noframes id='To9NH'>

                  <legend id='To9NH'><style id='To9NH'><dir id='To9NH'><q id='To9NH'></q></dir></style></legend>
                  • <bdo id='To9NH'></bdo><ul id='To9NH'></ul>
                    <i id='To9NH'><tr id='To9NH'><dt id='To9NH'><q id='To9NH'><span id='To9NH'><b id='To9NH'><form id='To9NH'><ins id='To9NH'></ins><ul id='To9NH'></ul><sub id='To9NH'></sub></form><legend id='To9NH'></legend><bdo id='To9NH'><pre id='To9NH'><center id='To9NH'></center></pre></bdo></b><th id='To9NH'></th></span></q></dt></tr></i><div id='To9NH'><tfoot id='To9NH'></tfoot><dl id='To9NH'><fieldset id='To9NH'></fieldset></dl></div>
                    <tfoot id='To9NH'></tfoot>