WEB开发网
开发学院数据库MSSQL Server 使用SQL Server 2000将现有代码作为Web服务提供 阅读

使用SQL Server 2000将现有代码作为Web服务提供

 2006-08-05 09:15:38 来源:WEB开发网   
核心提示: /*订单是父 XML元素 */Select 1 as Tag, NULL as Parent,Orders.OrderId AS [Order!1!OrderId],Orders.OrderStatus AS [Order!1!OrderStatus],Orders.OrderDate A

/*订单是父 XML元素 */

Select 1 as Tag, NULL as Parent,
Orders.OrderId AS [Order!1!OrderId],
Orders.OrderStatus AS [Order!1!OrderStatus],
Orders.OrderDate AS [Order!1!OrderDate],
Orders.SubTotal AS [Order!1!SubTotal],
Orders.Tax AS [Order!1!Tax],
Orders.ShippingHandling AS [Order!1!ShippingHandling],
Orders.ShipToName AS [Order!1!ShipToName],
Orders.ShipToAddressId AS [Order!1!ShipToAddressId],
NULL AS [OrderDetail!2!OrderDetailId],
NULL AS [OrderDetail!2!OrderId],
NULL AS [OrderDetail!2!ItemId],
NULL AS [OrderDetail!2!UnitPrice],
NULL AS [OrderDetail!2!Quantity]
from Orders
UNION ALL

/*订单详细信息是子 XML元素 */

select 2 as tag, 1 as parent,
Orders.OrderId AS [Order!1!OrderId],
NULL AS [Order!1!OrderStatus],
NULL AS [Order!1!OrderDate],
NULL AS [Order!1!SubTotal],
NULL AS [Order!1!Tax],
NULL AS [Order!1!ShippingHandling],
NULL AS [Order!1!ShipToName],
NULL AS [Order!1!ShipToAddressId],
OrderDetails.OrderDetailId AS [OrderDetail!2!OrderDetailId],
OrderDetails.OrderId AS [OrderDetail!2!OrderId],
OrderDetails.ItemId AS [OrderDetail!2!ItemId],
OrderDetails.UnitPrice AS [OrderDetail!2!UnitPrice],
OrderDetails.Quantity AS [OrderDetail!2!Quantity]
from Orders, OrderDetails
where Orders.OrderId = OrderDetails.OrderId
ORDER BY [Order!1!OrderId],[OrderDetail!2!OrderDetailId]
For XML EXPLICIT 写数据。

Tags:使用 SQL Server

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接