|
Execute the following SQL Server T-SQL
script in SSMS Query Editor to generate XML file for all store orders
with name starting with "I":
USE AdventureWorks;
SELECT s.[Name],
soh.CustomerID,
soh.SalesOrderID,
sod.SalesOrderID,
sod.LineTotal,
sod.ProductID,
Product.Name,
sod.OrderQty
FROM Sales.Store s,
Sales.Customer c,
Sales.SalesOrderHeader soh,
Sales.SalesOrderDetail sod,
Production.Product Product
WHERE c.CustomerID = soh.CustomerID
AND soh.SalesOrderID = sod.SalesOrderID
AND sod.ProductID = Product.ProductID
AND s.CustomerID = c.CustomerID
AND left(s.[Name],1) = 'I'
ORDER BY s.[Name],
soh.SalesOrderID
FOR XML AUTO ;
/*
<s Name="Ideal Components">
<soh CustomerID="51" SalesOrderID="53532">
<sod SalesOrderID="53532" LineTotal="2186.730000" ProductID="953" OrderQty="3">
<Product Name="Touring-2000 Blue, 60" />
</sod>
</soh>
<soh CustomerID="51" SalesOrderID="65274">
<sod SalesOrderID="65274" LineTotal="200.052000" ProductID="895" OrderQty="1">
<Product Name="LL Touring Frame - Blue, 50" />
</sod>
</soh>
<soh CustomerID="51" SalesOrderID="71905">
<sod SalesOrderID="71905" LineTotal="4291.326000" ProductID="954" OrderQty="3">
<Product Name="Touring-1000 Yellow, 46" />
</sod>
</soh>
</s>
......
*/
|