XML Enhancement in SQL Server 2005

博客介绍了SQL Server 2000和2005在XML查询方面的差异。2000的RAW模式FOR XML查询仅返回以属性为中心的XML,2005可结合ELEMENTS指令返回以元素为中心的XML。2000返回以元素为中心的XML时会省略空列,2005可通过特定选项为其生成带xsi:nil属性的空元素。

In SQL Server 2000, RAW mode FOR XML queries can return only attribute-centric XML. In SQL Server 2005, you can use the ELEMENTS directive with RAW mode queries to return element-centric XML. The following example shows how to use the ELEMENTS directive with RAW mode.

SELECT ProductID, Name, ListPrice
FROM Production.Product
FOR XML RAW, ELEMENTS

 

When element-centric XML is returned in SQL Server 2000, null columns are omitted in the results. In SQL Server 2005, you can specify that null columns should yield empty elements with the xsi:nil attribute by using the XSINIL option with the ELEMENTS directive in AUTO, RAW, and PATH mode queries or by using the elementxsinil column mode in EXPLICIT mode queries. The following examples show how to retrieve empty elements for null values.

-- Using XSINIL with ELEMENTS

SELECT ProductID, Name, Color

FROM Production.Product Product

FOR XML AUTO, ELEMENTS XSINIL

转载于:https://www.cnblogs.com/net2004/archive/2005/04/16/138669.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值