Microsoft SQL Server 2005 Best Practices


How to export all the product reviews to XML?


Execute the following script in Query Editor to export the product reviews into xml result:

use AdventureWorks;

select ProductID, Name, ListPrice,
(select ReviewerName, Comments
from Production.ProductReview pr
where pr.ProductID = p.ProductID
for xml auto, elements, type)
from Production.Product p
where p.ProductID in
(select ProductID from Production.ProductReview)
order by Name
for xml auto;


The World Leader in SQL Server Training
SQLUSA.com Home Page