USE CSOS_NEW_2
GO --(1)定义临时表
DECLARE @table TABLE(id INT IDENTITY(1,1),XMLDetail XML)
DECLARE @xml XML
SET @xml='<EBPCaseDetailType>
<openReason xmlns="http://www.ebay.com/marketplace/resolution/v1/services">Item not received</openReason>
<decisionReason xmlns="http://www.ebay.com/marketplace/resolution/v1/services">11002</decisionReason>
<decisionDate xmlns="http://www.ebay.com/marketplace/resolution/v1/services">2013-06-25T18:09:19Z</decisionDate>
<decision xmlns="http://www.ebay.com/marketplace/resolution/v1/services">SELLER_FAULT</decision>
<FVFCredited xmlns="http://www.ebay.com/marketplace/resolution/v1/services">false</FVFCredited>
<notCountedInBuyerProtectionCases xmlns="http://www.ebay.com/marketplace/resolution/v1/services">false</notCountedInBuyerProtectionCases>
<globalId xmlns="http://www.ebay.com/marketplace/resolution/v1/services">EBAY_UK</globalId>
<responseHistory xmlns="http://www.ebay.com/marketplace/resolution/v1/services">
<author>
<role>EBAY</role>
</author>
<activity>agentResolve</activity>
<creationDate>2013-06-25T18:10:03Z</creationDate>
</responseHistory>
<responseHistory xmlns="http://www.ebay.com/marketplace/resolution/v1/services">
<author>
<role>BUYER</role>
</author>
<activity>contactCustomerSupport</activity>
<creationDate>2013-06-25T12:24:53Z</creationDate>
</responseHistory>
<responseHistory xmlns="http://www.ebay.com/marketplace/resolution/v1/services">
<author>
<role>EBAY</role>
</author>
<activity>systemExpireGrace</activity>
<creationDate>2013-06-24T16:01:13Z</creationDate>
</responseHistory>
<responseHistory xmlns="http://www.ebay.com/marketplace/resolution/v1/services">
<note>Nothing has yet been received, if the item can be sent this week then please send it. If not then a refund please. Thankyou</note>
<author>
<role>BUYER</role>
</author>
<activity>create</activity>
<creationDate>2013-06-17T05:34:49Z</creationDate>
</responseHistory>
<agreedRefundAmount xmlns="http://www.ebay.com/marketplace/resolution/v1/services">0</agreedRefundAmount>
<paymentDetail xmlns="http://www.ebay.com/marketplace/resolution/v1/services">
<moneyMovement id="M.1">
<type>REFUND</type>
<fromParty>
<role>SELLER</role>
</fromParty>
<toParty>
<role>BUYER</role>
</toParty>
<amount currencyId="GBP">4.19</amount>
<paymentMethod>PAYPAL</paymentMethod>
<paypalTransactionId>5NE10254S0169263L</paypalTransactionId>
<status>SUCCESS</status>
<transactionDate>2013-06-25T18:09:18Z</transactionDate>
</moneyMovement>
</paymentDetail>
<detailStatus xmlns="http://www.ebay.com/marketplace/resolution/v1/services">4</detailStatus>
<initialBuyerExpectation xmlns="http://www.ebay.com/marketplace/resolution/v1/services">103</initialBuyerExpectation>
</EBPCaseDetailType>'; --(2)创建测数据
INSERT @table (XMLDetail )
VALUES (
@xml -- XMLDetail - xml
) SELECT *
FROM @table --(3)读取XML字段的数据
;
WITH XMLNAMESPACES('http://www.ebay.com/marketplace/resolution/v1/services' AS xs)
SELECT id,XMLDetail.value('(EBPCaseDetailType/xs:paymentDetail/xs:moneyMovement/xs:type)[1]','nvarchar(max)') AS 'Paymentype',
XMLDetail.value('(EBPCaseDetailType/xs:paymentDetail/xs:moneyMovement/xs:fromParty/xs:role)[1]','nvarchar(max)') AS 'Refundrole',
XMLDetail.value('(EBPCaseDetailType/xs:paymentDetail/xs:moneyMovement/xs:paypalTransactionId)[1]','nvarchar(max)') AS 'paypalTransactionId',
XMLDetail.value('(EBPCaseDetailType/xs:openReason)[1]','nvarchar(max)') AS 'openReason'
FROM @table

显示结果如下:

id  Paymentype  Refundrole    paypalTransactionId    openReason
1   REFUND       SELLER         5NE10254S0169263L  Item not received

  

SQL读取XML字段类型的信息的更多相关文章

  1. sql server sql查询数据库的表,字段,主键,自增,字段类型等信息

    1.查询数据表的属性(名称.说明.是否主键.数据类型.是否自增) SELECT t1.name columnName,case when t4.id is null then 'false' else ...

  2. SQL Server数据库字段类型说明

    SQL Server数据库字段类型说明 目前Sql Server 数据库一共有X个字段类型,大体分为9类,分别是字符串类型.二进制码字符串数据类型.Unincode字符串数据.整数类型.精确数据类型. ...

  3. 修改SQL数据库中表字段类型时,报“一个或多个对象访问此列”错误的解决方法

    在SQL数据库中使用SQL语句(格式:alter table [tablename] alter column [colname] [newDataType])修改某表的字段类型时,报一下错误:由于一 ...

  4. FIREDAC不能识别SQL的某些字段类型

    FIREDAC不能识别SQL的某些字段类型 经常见有网友有类似的提问:请问各位,在DataSnap中使用SQL数据SUM函数,如果是统计浮点型数值的话,返回是乱码,哪位是什么原因?  其实这不是DAT ...

  5. Oracle使用SQL语句修改字段类型

    Oracle使用SQL语句修改字段类型 1.如果表中没有数据 Sql代码 1 2 3 alter table 表名 modify (字段名1 类型,字段名2 类型,字段名3 类型.....)  alt ...

  6. SQL语句修改字段类型与第一次SQLServer试验解答

    SQL语句修改字段类型 mysql中 alert table name modify column name type; 例子:修改user表中的name属性类型为varchar(50) alert ...

  7. (转)SQL对Xml字段的操作

    T-Sql操作Xml数据 一.前言 SQL Server 2005 引入了一种称为 XML 的本机数据类型.用户可以创建这样的表,它在关系列之外还有一个或多个 XML 类型的列:此外,还允许带有变量和 ...

  8. SQL对Xml字段的操作

    转:http://www.cnblogs.com/youring2/archive/2008/11/27/1342288.html T-Sql操作Xml数据 一.前言 SQL Server 2005 ...

  9. (轉載)sql server xml字段的操作

    原文轉自:http://blog.csdn.net/hliq5399/article/details/8315373 另外可參考:https://msdn.microsoft.com/en-us/li ...

随机推荐

  1. java.lang.reflection打印一个类的全部信息

    package com.ljy.chapter5; import java.lang.reflect.Constructor; import java.lang.reflect.Field; impo ...

  2. Codeforces 474E - Pillars

    一眼看上去非常像最长不下降子序列. 然后比赛的时候对每个答案长度为k的序列,维护最后一个数的最大值和最小值. 当时不知道为什么认为从长度最长倒推至前面不会太长,于是心满意足地敲了个O(n^2).结果T ...

  3. Mac OS X 系统下快速显示隐藏文件的方法(使用Automator创建workflow)

    有的时候需要显系统中的隐藏文件,在 Mac 中不像windows系统那么方便(勾选选项就能够操作),需要在 Terminal 中执行: localhost:~ mx$ defaults write c ...

  4. H5中需要掌握的 ANIMATION 动画效果

    CSS3的动画在PC网页上或者APP上用得越来越多,比如H5页面的应用,目前在营销传播上的意义比较大,还有企业官网或者APP主要介绍也用得比较多,当然还有很多地方都用到.所以学习css的动画也迫在眉睫 ...

  5. ThinkPHP 笔记

    1.循环中使用比较运算符 <volist name="subjects" id="v">       <option value=" ...

  6. wdcp-apache配置错误导致进程淤积进而内存吃紧

    内存总是越来越少,虚拟内存使用越来越多 首先确定到底是什么占用了大量的内存 可以看到,大部分内存被闲置的httpd进程占用 且当我重启mysql服务后,内存没有出现明显变化,但是当我重启apache时 ...

  7. ajax xmlhttprequest status

    status 0**:未被始化 status 1**:请求收到,继续处理 status 2**:操作成功收到,分析.接受 status 3**:完成此请求必须进一步处理 status 4**:请求包含 ...

  8. [css][移动设备]禁止横竖屏时内容自动调整

    参考:http://www.kankanews.com/ICkengine/archives/106643.shtml iOS下当竖屏转向横屏的时候,发现内容字体会自动变大,通过各种方法设置字体大小都 ...

  9. PHP数据学习-二维数组【3】

    <?php // $project = array( // array("bai",12,23.0), // array("zeng",34,12.0), ...

  10. 去除VS2010中中文注释下的红色波浪线

    1,中文注释以分号结尾 2,Assist X 菜单栏->Assist X Option->Underline 选择“min”.