久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='sPx8R'><tr id='sPx8R'><dt id='sPx8R'><q id='sPx8R'><span id='sPx8R'><b id='sPx8R'><form id='sPx8R'><ins id='sPx8R'></ins><ul id='sPx8R'></ul><sub id='sPx8R'></sub></form><legend id='sPx8R'></legend><bdo id='sPx8R'><pre id='sPx8R'><center id='sPx8R'></center></pre></bdo></b><th id='sPx8R'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sPx8R'><tfoot id='sPx8R'></tfoot><dl id='sPx8R'><fieldset id='sPx8R'></fieldset></dl></div>
    1. <tfoot id='sPx8R'></tfoot>
      <legend id='sPx8R'><style id='sPx8R'><dir id='sPx8R'><q id='sPx8R'></q></dir></style></legend>

    2. <small id='sPx8R'></small><noframes id='sPx8R'>

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

        帶有 SQL 的 XML 節點

        XML nodes with SQL(帶有 SQL 的 XML 節點)
        1. <tfoot id='vzWBF'></tfoot>

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

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

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

                • 本文介紹了帶有 SQL 的 XML 節點的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有以下 XML 數據,并希望按如下方式在 KS 中獲取數據:

                  I have the following XML data and would like to get data inside KS as row as follows:

                  <DW>
                    <KS>
                      <KeyInfo Name="IlluSetting">
                        <KeyTypeValue>Text</KeyTypeValue>
                        <ValueString>yDipol90</ValueString>
                      </KeyInfo>
                       <KeyInfo Name="IlluSetting2">
                        <KeyTypeValue>Text</KeyTypeValue>
                        <ValueString>yDipol</ValueString>
                      </KeyInfo>
                    </KS>
                    <MDESC>Tx [mrad]</MDESC>
                     <MNUMBER>0.12102</MNUMBER>
                  </DW>
                  <DW>
                    <KS>
                      <KeyInfo Name="IlluSetting3">
                        <KeyTypeValue>Text</KeyTypeValue>
                        <ValueString>yDipol80</ValueString>
                      </KeyInfo>
                    </KS>
                    <MDESC>Ty [mrad]</MDESC>
                    <MNUMBER>0.12102</MNUMBER>
                  </DW>
                  

                  有什么辦法可以得到一個具有以下輸出的表格:

                  Is there any way to get a Table with the following output:

                  Name            ValueString     Name            ValueString
                  -----------------------------------------------------------
                  IlluSetting     yDipol90        IlluSetting2    yDipol
                  IlluSetting3    yDipol80    
                  

                  表示<KS>...</KS>里面的數據會排成一行顯示

                  which means that the data inside <KS>... </KS> will be shown in a row

                  非常感謝

                  推薦答案

                  請嘗試以下解決方案.我們在這里所做的稱為粉碎,即將 XML 轉換為矩形/關系格式.

                  Please try the following solution. What we are doing here is called shredding, i.e. converting XML into rectangular/relational format.

                  我正在拍攝,因為沒有提供DDL 和樣本數據群.

                  I am shooting from the hip because DDL and sample data population were not provided.

                  由于缺少根元素,提供的 XML 格式不正確,但 SQL Server 允許處理 XML 片段.

                  The provided XML is not well-formed due to missing root element, but SQL Server allows to handle XML fragments.

                  我們正在使用 XQuery 及其 .nodes().value() 方法.

                  We are using XQuery and its .nodes() and .value() methods.

                  SQL,方法 #1

                  -- DDL and sample data population, start
                  DECLARE @xml XML =
                  N'<DW>
                      <KS>
                          <KeyInfo Name="IlluSetting">
                              <KeyTypeValue>Text</KeyTypeValue>
                              <ValueString>yDipol90</ValueString>
                          </KeyInfo>
                          <KeyInfo Name="IlluSetting2">
                              <KeyTypeValue>Text</KeyTypeValue>
                              <ValueString>yDipol</ValueString>
                          </KeyInfo>
                      </KS>
                      <MDESC>Tx [mrad]</MDESC>
                      <MNUMBER>0.12102</MNUMBER>
                  </DW>
                  <DW>
                      <KS>
                          <KeyInfo Name="IlluSetting3">
                              <KeyTypeValue>Text</KeyTypeValue>
                              <ValueString>yDipol80</ValueString>
                          </KeyInfo>
                      </KS>
                      <MDESC>Ty [mrad]</MDESC>
                      <MNUMBER>0.12102</MNUMBER>
                  </DW>';
                  -- DDL and sample data population, end
                  
                  SELECT c.value('KeyInfo[1]/@Name', 'VARCHAR(30)') AS name1
                      , c.value('(KeyInfo[1]/ValueString/text())[1]', 'VARCHAR(30)') AS ValueString1
                      , COALESCE(c.value('KeyInfo[2]/@Name', 'VARCHAR(30)'), '') AS name2
                      , COALESCE(c.value('(KeyInfo[2]/ValueString/text())[1]', 'VARCHAR(30)'), '') AS ValueString2
                  FROM @xml.nodes('/DW/KS') AS t(c);
                  

                  輸出

                  +--------------+--------------+--------------+--------------+
                  |    name1     | ValueString1 |    name2     | ValueString2 |
                  +--------------+--------------+--------------+--------------+
                  | IlluSetting  | yDipol90     | IlluSetting2 | yDipol       |
                  | IlluSetting3 | yDipol80     |              |              |
                  +--------------+--------------+--------------+--------------+
                  

                  SQL,方法 #2

                  DECLARE @CrLf CHAR(2) = CHAR(13) + CHAR(10)
                     , @tokenCounter INT
                     , @i INT = 1;
                  
                  -- Calculate max number of tokens in the <KS>
                  SET @tokenCounter = (SELECT MAX(c.value('count(KeyInfo)', 'INT'))
                  FROM @xml.nodes('/DW/KS') AS t(c));
                  
                  DECLARE @SQL NVARCHAR(MAX) = 'SELECT ';
                  
                  WHILE @i <= @tokenCounter BEGIN
                      SET @SQL += IIF(@i>1,', ','') + 'COALESCE(c.value(''KeyInfo[' + CAST(@i AS VARCHAR(3)) + ']/@Name'', ''VARCHAR(30)''), '''') AS NAME' + CAST(@i AS VARCHAR(3)) + @CrLf
                      SET @SQL += ', COALESCE(c.value(''(KeyInfo[' + CAST(@i AS VARCHAR(3)) + ']/ValueString/text())[1]'', ''VARCHAR(30)''), '''') AS ValueString' + CAST(@i AS VARCHAR(3)) + @CrLf
                  
                      SET @i += 1
                  END
                  
                  SET @SQL += 'FROM @xml.nodes(''/DW/KS'') AS t(c);';
                  
                  -- just to see it
                  PRINT @sql;
                  
                  -- we are ready at this point
                  EXEC sp_executesql @stmt = @SQL, @params = N'@xml xml', @xml = @xml;
                  

                  這篇關于帶有 SQL 的 XML 節點的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產品、類別和元數據的 SQL 查詢 woocommerce/wordpress)
                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                  How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                  Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 ExecuteNonQuery()?)
                  How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)

                  <tfoot id='MaFxj'></tfoot>
                    • <bdo id='MaFxj'></bdo><ul id='MaFxj'></ul>
                          <tbody id='MaFxj'></tbody>

                        <i id='MaFxj'><tr id='MaFxj'><dt id='MaFxj'><q id='MaFxj'><span id='MaFxj'><b id='MaFxj'><form id='MaFxj'><ins id='MaFxj'></ins><ul id='MaFxj'></ul><sub id='MaFxj'></sub></form><legend id='MaFxj'></legend><bdo id='MaFxj'><pre id='MaFxj'><center id='MaFxj'></center></pre></bdo></b><th id='MaFxj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MaFxj'><tfoot id='MaFxj'></tfoot><dl id='MaFxj'><fieldset id='MaFxj'></fieldset></dl></div>
                      1. <legend id='MaFxj'><style id='MaFxj'><dir id='MaFxj'><q id='MaFxj'></q></dir></style></legend>

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

                            主站蜘蛛池模板: 国产一区二区三区四区五区加勒比 | 99精品免费视频 | 亚洲乱码国产乱码精品精的特点 | 五月婷婷激情 | 日韩一区二区在线看 | 国产在线h| 青青草免费在线视频 | 精品视频在线观看 | 瑟瑟视频在线看 | 99色综合 | aaaa一级毛片 | 国产欧美精品一区二区 | 精品久久中文 | 91精品久久久久久久久久入口 | 中文字幕乱码亚洲精品一区 | 一区二区中文字幕 | 午夜免费看 | www.xxxx欧美| 欧美日韩视频在线 | 中文字幕一区二区三区不卡在线 | 男女午夜激情视频 | 亚洲第一在线视频 | 亚洲在线免费 | 欧美日韩精品在线免费观看 | 久久精品一 | 国产精品成人一区二区三区吃奶 | 久久精品国产久精国产 | 天天爱天天操 | 欧美一卡二卡在线观看 | 综合一区二区三区 | 日韩欧美网 | 午夜理伦三级理论三级在线观看 | 日本不卡一区二区三区在线观看 | 在线精品国产 | 五月香婷婷 | 一二三四在线视频观看社区 | 国产一区二区三区在线看 | 亚洲第一成人av | 久久久久国色av免费观看性色 | 国产日韩一区二区 | 国产一在线 |