SQL读取XML字段类型的信息
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字段类型的信息的更多相关文章
- sql server sql查询数据库的表,字段,主键,自增,字段类型等信息
1.查询数据表的属性(名称.说明.是否主键.数据类型.是否自增) SELECT t1.name columnName,case when t4.id is null then 'false' else ...
- SQL Server数据库字段类型说明
SQL Server数据库字段类型说明 目前Sql Server 数据库一共有X个字段类型,大体分为9类,分别是字符串类型.二进制码字符串数据类型.Unincode字符串数据.整数类型.精确数据类型. ...
- 修改SQL数据库中表字段类型时,报“一个或多个对象访问此列”错误的解决方法
在SQL数据库中使用SQL语句(格式:alter table [tablename] alter column [colname] [newDataType])修改某表的字段类型时,报一下错误:由于一 ...
- FIREDAC不能识别SQL的某些字段类型
FIREDAC不能识别SQL的某些字段类型 经常见有网友有类似的提问:请问各位,在DataSnap中使用SQL数据SUM函数,如果是统计浮点型数值的话,返回是乱码,哪位是什么原因? 其实这不是DAT ...
- Oracle使用SQL语句修改字段类型
Oracle使用SQL语句修改字段类型 1.如果表中没有数据 Sql代码 1 2 3 alter table 表名 modify (字段名1 类型,字段名2 类型,字段名3 类型.....) alt ...
- SQL语句修改字段类型与第一次SQLServer试验解答
SQL语句修改字段类型 mysql中 alert table name modify column name type; 例子:修改user表中的name属性类型为varchar(50) alert ...
- (转)SQL对Xml字段的操作
T-Sql操作Xml数据 一.前言 SQL Server 2005 引入了一种称为 XML 的本机数据类型.用户可以创建这样的表,它在关系列之外还有一个或多个 XML 类型的列:此外,还允许带有变量和 ...
- SQL对Xml字段的操作
转:http://www.cnblogs.com/youring2/archive/2008/11/27/1342288.html T-Sql操作Xml数据 一.前言 SQL Server 2005 ...
- (轉載)sql server xml字段的操作
原文轉自:http://blog.csdn.net/hliq5399/article/details/8315373 另外可參考:https://msdn.microsoft.com/en-us/li ...
随机推荐
- [转载]hadoop SecondNamenode详解
SecondNamenode名字看起来很象是对第二个Namenode,要么与Namenode一样同时对外提供服务,要么相当于Namenode的HA.真正的了解了SecondNamenode以后,才发现 ...
- SGU 220.Little Bishops(DP)
题意: 给一个n*n(n<=10)的棋盘,放上k个主教(斜走),求能放置的种类总数. Solution: 一眼看上去感觉是状压DP,发现状态太多,没办法存下来... 下面是一个十分巧妙的处理: ...
- 【POJ1195】【二维树状数组】Mobile phones
Description Suppose that the fourth generation mobile phone base stations in the Tampere area operat ...
- confluence的权限管理
上一篇解讲如何破解,安装confluence5.8.10,这次主要是看权限管理的实现.因为公司对知识的管理不仅是简单的分享,还要求不同权限的人看到不同的内容,所以在一开始就需要对权限这一块有所了解,以 ...
- nuc970连接jlink进行单步调试的设置
在 USB mode 下, 先跟 NuWriter 接上, 然后用以下的设定. 按 Keil 的 debug (不是 download to flash)就可以接上了.
- zoj3839-Poker Face
#include<cstdio>int n;void P(int i,int j,int n,int f){ if(i==n){ for(int k=1;k<=n;k++)print ...
- Sublime text3 JS语法检测工具安装及使用
Sublime text3 JS语法检测工具安装及使用 工具/原料 sublime text3 nodejs sublimeLinter sublimeLinter-jshint 方法/步骤 首先ct ...
- 干掉Google字体,WordPress速度暴涨
2014年7月7日23:40:31 因为Google被墙,WordPress引用的Google字体总会加载很长时间,严重影响打开速度. 安装WordPress插件 Disable Google Fon ...
- OC学习总结之面向对象和类
OC学习总结之面向对象和类 Objective-c是c语言的母集合,它的原意就是在原始的c语言的主体上加入面向对象的特性.1.面向对象和面向过程 面向对象和面向过程是编程的两种思考方式.面向对象 ...
- House of hello恶搞凯莉迷你包
欧洲站 House of hello恶搞凯莉迷你包 最近淘宝卖的很疯,看看价格,俺咂舌不已 :1300-1600 今年迷你包卖的很疯我是知道的,迷你包今年没有买一个也是不行的! 剔除暴利,便宜的亲们不 ...