[ FOR { BROWSE | XML { RAW | AUTO | EXPLICIT } [ , XMLDATA ] [ , ELEMENTS ] [ , BINARY BASE64 ] } ] eg.SELECT c.CompanyName, o.OrderID, o.OrderDate, p.ProductName, p.Quantity, p.UnitPrice, p.Total FROM Customers AS c JOIN Orders AS o ON c.CustomerID = o.CustomerID JOIN ( SELECT od.OrderID, pr.ProductName, od.Quantity, od.UnitPrice, od.Quantity * od.UnitPrice AS total FROM Products AS pr JOIN [Order Details] AS od ON pr.ProductID = od.ProductID ) AS p ON o.OrderID = p.OrderID FOR XML AUTO下面是部分结果:<c CompanyName="Vins et alcools Chevalier"> <o OrderID="10248" OrderDate="1996-07-04T00:00:00"> <pr ProductName="Queso Cabrales"> <od Quantity="12" UnitPrice="14.0000" total="168.0000"/> </pr> <pr ProductName="Singaporean Hokkien Fried Mee"> <od Quantity="10" UnitPrice="9.8000" total="98.0000"/> </pr> </c>
你的问题需要 XML 和 DTS/Schema 一起工作才行。 XML相当于数据表, DTS/Schema 相当于表格的定义,自然包括主键、外键这些东西。 好比要显示 XML 文件中的数据,需要 XML 和 XSL 一同工作一样。 可以看看蔫老虎的《无废话XML》,网上到处都是电子版,概念和例子都有了。 SQL2000的联机帮助里面也有现成的例子。
[ , XMLDATA ]
[ , ELEMENTS ]
[ , BINARY BASE64 ]
}
] eg.SELECT c.CompanyName,
o.OrderID,
o.OrderDate,
p.ProductName,
p.Quantity,
p.UnitPrice,
p.Total
FROM Customers AS c
JOIN
Orders AS o
ON
c.CustomerID = o.CustomerID
JOIN
(
SELECT od.OrderID,
pr.ProductName,
od.Quantity,
od.UnitPrice,
od.Quantity * od.UnitPrice AS total
FROM Products AS pr
JOIN
[Order Details] AS od
ON
pr.ProductID = od.ProductID
) AS p
ON
o.OrderID = p.OrderID
FOR XML AUTO下面是部分结果:<c CompanyName="Vins et alcools Chevalier">
<o OrderID="10248" OrderDate="1996-07-04T00:00:00">
<pr ProductName="Queso Cabrales">
<od Quantity="12" UnitPrice="14.0000" total="168.0000"/>
</pr>
<pr ProductName="Singaporean Hokkien Fried Mee">
<od Quantity="10" UnitPrice="9.8000" total="98.0000"/>
</pr>
</c>
好比要显示 XML 文件中的数据,需要 XML 和 XSL 一同工作一样。
可以看看蔫老虎的《无废话XML》,网上到处都是电子版,概念和例子都有了。
SQL2000的联机帮助里面也有现成的例子。