Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

FOR XML PATH('Product')

Posted on 2011-05-02
3
Medium Priority
?
279 Views
Last Modified: 2012-05-11
hi experts, i have this query
SELECT ProductID AS "@ProductID",
       Name AS "*",
       Size AS "Description/@Size",
       Color AS "Description/text()"
FROM Production.Product
ORDER BY Name
FOR XML PATH('Product')
can explain to me that means the nomenclature used in select
con-xml.jpg
sin-xml.jpg
0
Comment
Question by:enrique_aeo
  • 2
3 Comments
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 2000 total points
ID: 35508396
Please check the following link:

Using PATH Mode
http://msdn.microsoft.com/en-us/library/ms189885%28v=SQL.100%29.aspx
0
 

Author Comment

by:enrique_aeo
ID: 35518043
is much information, you can explain just what I'm asking. Thanks
0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 2000 total points
ID: 35700340
There you go.  I hope this helps:

SELECT ProductID AS "@ProductID",      -- Set the attribute <Product ProductID=> to the value of the ProductID column
       Name AS "*",                    -- Set the text of <Product> to the value of the Name column
       Size AS "Description/@Size",    -- Set the attribute <Description Size=> to the value of the Size column
       Color AS "Description/text()"   -- Set the text of <Description> to the value of the Color column
FROM Production.Product
ORDER BY Name
FOR XML PATH('Product')                -- For each row generate a XML Tag <Product>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question