pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

    <legend id='dpUgK'><style id='dpUgK'><dir id='dpUgK'><q id='dpUgK'></q></dir></style></legend>

      • <bdo id='dpUgK'></bdo><ul id='dpUgK'></ul>
      <tfoot id='dpUgK'></tfoot>

    1. 將具有相同標記的 XML 值分成不同的行 SQL Server

      Separating XML values with the same tags into different rows SQL Server(將具有相同標記的 XML 值分成不同的行 SQL Server)

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

                本文介紹了將具有相同標記的 XML 值分成不同的行 SQL Server的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我有一個要解析的 XML 文件.XML 是使用

                I have an XML File which I am trying to parse. The XML was created through Excel using

                另存為 XML

                因為 XML 文件是從 Microsoft Excel 創建的,所以它有這個標題:

                Because the XML file was created from Microsoft Excel, it has this header:

                <?xml version="1.0"?>
                <?mso-application progid="Excel.Sheet"?>
                <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
                 xmlns:o="urn:schemas-microsoft-com:office:office"
                 xmlns:x="urn:schemas-microsoft-com:office:excel"
                 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
                 xmlns:html="http://www.w3.org/TR/REC-html40">
                

                我試圖提取的數據是這樣設置的:

                The data I am trying to extract is set up in blocks like this:

                <Row ss:AutoFitHeight="0" ss:Height="30">
                    <Cell ss:StyleID="s22"/>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">Jane Doe</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">JaneDoe</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">XYZ</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">(555) 555-5555</Data></Cell>
                    <Cell ss:StyleID="s22"/>
                   </Row>
                

                現在,我的查詢如下所示:

                Right now, my query looks like this:

                ;WITH XMLNAMESPACES ('urn:schemas-microsoft-com:office:spreadsheet' as ss)
                
                select * from (
                select X.value('local-name(.)[1]','varchar(max)') as Name,
                X.value('.[1]','varchar(max)') as Value
                from @allUsers.nodes('//*') as T(X)
                    ) a
                where Name  = 'Data'
                

                并給我這些結果:

                Name    Value
                ----    -----------
                Data    Jane Doe
                Data    JaneDoe
                Data    XYZ
                Data    (555)555-5555
                

                我想做的是將它分成 4 行,所以我有類似的東西:

                What I would like to do is separate this into 4 rows, so I have something like:

                Name      UserName    Address    Phone
                -----     ----------  ---------  ----------
                Jane Doe  JaneDoe     XYZ        (555)-555-5555
                

                我嘗試選擇一列作為

                X.value('.[2]','varchar(max)') as UserName
                

                但我只是得到了所有的 NULL 值.

                but I just get all NULL values for that.

                有沒有辦法做到這一點?

                Is there any way to do this?

                XML 文件的一般結構如下:

                The general structure of the XML file looks like:

                <Workbook>
                  <DocumentProperties>
                  </DocumentProperties>
                  <ExcelWorkbook>
                  </ExcelWorkbook>
                  <Styles>
                    <Style>
                    </Style>
                  </Styles>
                  <Worksheet>
                    <Table>
                      <Column.../>
                      <Column.../>
                      <Column.../>
                      <Row>
                        <Cell.../>
                        <Cell><Data>...</Data></Cell>
                        <Cell><Data>...</Data></Cell>
                        <Cell><Data>...</Data></Cell>
                        <Cell><Data>...</Data></Cell>
                        <Cell.../>
                      </Row>
                      ...
                    </Table>
                  </Worksheet>
                

                我想要獲取的信息在 ...</Data> 字段

                and the information I am trying to get is in the <Data>...</Data> field

                編輯

                從我表述這個問題的方式來看,標題名稱似乎已經被編入,但它們實際上被讀取為 <;/Cell>.我也不確定這部分的用途是什么

                From the way I phrased the question, it would seem like the header names are already programmed in, but they are actually read as rows in <Cell><Data><Data/></Cell>. I am also not sure what purpose the part serves

                這是部分的開始:

                <Table ss:ExpandedColumnCount="6" ss:ExpandedRowCount="2685" x:FullColumns="1"
                   x:FullRows="1">
                   <Column ss:AutoFitWidth="0" ss:Width="26.25"/>
                   <Column ss:AutoFitWidth="0" ss:Width="117" ss:Span="3"/>
                   <Column ss:Index="6" ss:AutoFitWidth="0" ss:Width="29.25"/>
                   <Row ss:AutoFitHeight="0" ss:Height="60"> --Contains the header names
                    <Cell ss:StyleID="s22"/>
                    <Cell ss:StyleID="s23"><Data ss:Type="String">Name</Data></Cell>
                    <Cell ss:StyleID="s23"><Data ss:Type="String">UserName</Data></Cell>
                    <Cell ss:StyleID="s23"><Data ss:Type="String">Address</Data></Cell>
                    <Cell ss:StyleID="s23"><Data ss:Type="String">Telephone Number</Data></Cell>
                    <Cell ss:StyleID="s22"/>
                   </Row>
                
                   <Row ss:AutoFitHeight="0" ss:Height="30"> --First record I would like to extract
                    <Cell ss:StyleID="s22"/>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">John Smith</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">JSmith</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">ABC</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">(999) 999-9999</Data></Cell>
                    <Cell ss:StyleID="s22"/>
                   </Row>
                

                推薦答案

                同一用戶提出了兩個非常相似的問題.OP 決定刪除一個并在此處合并,并要求我將我的答案從那里復制到此線程.

                There were two very similar question by the same user. The OP decided to delete one and combine this here and asked me to copy my answer from there to this thread.

                注意必須聲明為DEFAULT"的 xmlns-namespace:

                Be aware of the xmlns-namespace which must be declared as "DEFAULT":

                簡化了您的 XML,但這個想法應該沒問題...

                Simplified your XML, but the idea should be OK...

                DECLARE @allUsers XML=
                '<?xml version="1.0"?>
                <?mso-application progid="Excel.Sheet"?>
                <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
                 xmlns:o="urn:schemas-microsoft-com:office:office"
                 xmlns:x="urn:schemas-microsoft-com:office:excel"
                 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
                 xmlns:html="http://www.w3.org/TR/REC-html40">
                 <Worksheet>
                 <Table>
                   <Row ss:AutoFitHeight="0" ss:Height="30">
                    <Cell ss:StyleID="s22"/>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">Jane Doe</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">JaneDoe</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">XYZ</Data></Cell>
                    <Cell ss:StyleID="s24"><Data ss:Type="String">(555) 555-5555</Data></Cell>
                    <Cell ss:StyleID="s22"/>
                   </Row>
                   </Table>
                 </Worksheet>   
                </Workbook>';
                
                ;WITH XMLNAMESPACES ('urn:schemas-microsoft-com:office:spreadsheet' as ss
                                     ,DEFAULT 'urn:schemas-microsoft-com:office:spreadsheet')
                SELECT T.X.value('Cell[1]/Data[1]','varchar(max)') AS DontKnow1
                      ,T.X.value('Cell[2]/Data[1]','varchar(max)') AS Name
                      ,T.X.value('Cell[3]/Data[1]','varchar(max)') AS UserName
                      ,T.X.value('Cell[4]/Data[1]','varchar(max)') AS DontKnow2
                      ,T.X.value('Cell[5]/Data[1]','varchar(max)') AS Telephone
                      ,T.X.value('Cell[6]/Data[1]','varchar(max)') AS DontKnow3
                FROM @allUsers.nodes('/Workbook/Worksheet/Table/Row') as T(X)
                

                這篇關于將具有相同標記的 XML 值分成不同的行 SQL Server的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)
              • <legend id='lOt7b'><style id='lOt7b'><dir id='lOt7b'><q id='lOt7b'></q></dir></style></legend>

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

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

                  • <tfoot id='lOt7b'></tfoot>

                        • <bdo id='lOt7b'></bdo><ul id='lOt7b'></ul>
                            <tbody id='lOt7b'></tbody>
                          主站蜘蛛池模板: 山东led显示屏,山东led全彩显示屏,山东LED小间距屏,临沂全彩电子屏-山东亚泰视讯传媒有限公司 | 破碎机_上海破碎机_破碎机设备_破碎机厂家-上海山卓重工机械有限公司 | 高精度电阻回路测试仪-回路直流电阻测试仪-武汉特高压电力科技有限公司 | 检验科改造施工_DSA手术室净化_导管室装修_成都特殊科室建设厂家_医疗净化工程公司_四川华锐 | 螺旋绞龙叶片,螺旋输送机厂家,山东螺旋输送机-淄博长江机械制造有限公司 | 科研ELISA试剂盒,酶联免疫检测试剂盒,昆虫_植物ELISA酶免试剂盒-上海仁捷生物科技有限公司 | 上海新光明泵业制造有限公司-电动隔膜泵,气动隔膜泵,卧式|立式离心泵厂家 | 制氮设备_PSA制氮机_激光切割制氮机_氮气机生产厂家-苏州西斯气体设备有限公司 | 英超直播_英超免费在线高清直播_英超视频在线观看无插件-24直播网 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 广东风淋室_广东风淋室厂家_广东风淋室价格_广州开源_传递窗_FFU-广州开源净化科技有限公司 | 地源热泵一体机,地源热泵厂家-淄博汇能环保设备有限公司 | 汽液过滤网厂家_安平县银锐丝网有限公司 | 制氮设备_PSA制氮机_激光切割制氮机_氮气机生产厂家-苏州西斯气体设备有限公司 | 便携式高压氧舱-微压氧舱-核生化洗消系统-公众洗消站-洗消帐篷-北京利盟救援 | 深圳湾1号房价_深圳湾1号二手房源 | 北京晚会活动策划|北京节目录制后期剪辑|北京演播厅出租租赁-北京龙视星光文化传媒有限公司 | 老城街小面官网_正宗重庆小面加盟技术培训_特色面馆加盟|牛肉拉面|招商加盟代理费用多少钱 | 悬浮拼装地板_幼儿园_篮球场_悬浮拼接地板-山东悬浮拼装地板厂家 | 罗茨真空机组,立式无油往复真空泵,2BV水环真空泵-力侨真空科技 | 联系我们-腾龙公司上分客服微信19116098882 | 洛阳防爆合格证办理-洛阳防爆认证机构-洛阳申请国家防爆合格证-洛阳本安防爆认证代办-洛阳沪南抚防爆电气技术服务有限公司 | 扬子叉车厂家_升降平台_电动搬运车|堆高车-扬子仓储叉车官网 | 精密模具制造,注塑加工,吹塑和吹瓶加工,EPS泡沫包装生产 - 济南兴田塑胶有限公司 | 冷却塔减速机器_冷却塔皮带箱维修厂家_凉水塔风机电机更换-广东康明冷却塔厂家 | 防爆电机生产厂家,YBK3电动机,YBX3系列防爆电机,YBX4节防爆电机--河南省南洋防爆电机有限公司 | 济南电缆桥架|山东桥架-济南航丰实业有限公司 | 钢绞线万能材料试验机-全自动恒应力两用机-混凝土恒应力压力试验机-北京科达京威科技发展有限公司 | 齿辊分级破碎机,高低压压球机,立式双动力磨粉机-郑州长城冶金设备有限公司 | 液氮罐_液氮容器_自增压液氮罐_杜瓦瓶_班德液氮罐厂家 | CTP磁天平|小电容测量仪|阴阳极极化_双液系沸点测定仪|dsj电渗实验装置-南京桑力电子设备厂 | 蓄电池回收,ups电池后备电源回收,铅酸蓄电池回收,机房电源回收-广州益夫铅酸电池回收公司 | 三防漆–水性三防漆–水性浸渍漆–贝塔三防漆厂家 | COD分析仪|氨氮分析仪|总磷分析仪|总氮分析仪-圣湖Greatlake | 天空彩票天下彩,天空彩天空彩票免费资料,天空彩票与你同行开奖,天下彩正版资料大全 | 电气控制系统集成商-PLC控制柜变频控制柜-非标自动化定制-电气控制柜成套-NIDEC CT变频器-威肯自动化控制 | 安全,主动,被动,柔性,山体滑坡,sns,钢丝绳,边坡,防护网,护栏网,围栏,栏杆,栅栏,厂家 - 护栏网防护网生产厂家 | 伟秀电气有限公司-10kv高低压开关柜-高低压配电柜-中置柜-充气柜-欧式箱变-高压真空断路器厂家 | 专注氟塑料泵_衬氟泵_磁力泵_卧龙泵阀_化工泵专业品牌 - 梭川泵阀 | 聚氨酯催化剂K15,延迟催化剂SA-1,叔胺延迟催化剂,DBU,二甲基哌嗪,催化剂TMR-2,-聚氨酯催化剂生产厂家 | 抓斗式清污机|螺杆式|卷扬式启闭机|底轴驱动钢坝|污水处理闸门-方源水利机械 |