Login
Search
Welcome to the iTechForums.
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
To register now click here.
Latest Threads
Advertisements
Forum Statistics
Threads:
Posts: 2
Members:
Number of Users Online:
Welcome to our newest member,
Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2008, 01:26 AM
vb.net vb.net is offline
Junior Member
 
Join Date: May 2008
Posts: 3
Default

Export SQL query to XML?


How can I export the results of a SQL (2000) query into an XML file?

I want the results to be something like:

<records>
<record>
<firstname>John</firstname>
<lastname>Doe</lastname>
<product>book</product>
</record>
</records>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 05-15-2008, 01:30 AM
crazy_fuzzy_bunny crazy_fuzzy_bunny is offline
Junior Member
 
Join Date: May 2008
Posts: 1
Default

You can execute SQL queries to return results as XML rather than standard rowsets. These queries can be executed directly or from within stored procedures. To retrieve results directly, you use the FOR XML clause of the SELECT statement, and within the FOR XML clause you specify an XML mode: RAW, AUTO, or EXPLICIT.

For example, this SELECT statement retrieves information from Customers and Orders table in the Northwind database. This query specifies the AUTO mode in the FOR XML clause:

SELECT Customers.CustomerID, ContactName, CompanyName,
Orders.CustomerID, OrderDate
FROM Customers, Orders
WHERE Customers.CustomerID = Orders.CustomerID
AND (Customers.CustomerID = N'ALFKI'
OR Customers.CustomerID = N'XYZAA')
ORDER BY Customers.CustomerID
FOR XML AUTO

Whereas you can use the FOR XML clause to retrieve data as an XML document, you can use the Transact-SQL OPENXML function to insert data represented as an XML document. OPENXML is a rowset provider similar to a table or a view, providing a rowset over in-memory XML documents. OPENXML allows access to XML data as if it is a relational rowset by providing a rowset view of the internal representation of an XML document. The records in the rowset can be stored in database tables. OPENXML can be used in SELECT, and SELECT INTO statements where a source table or view can be specified.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
for php query psql? chris y PHP 1 05-06-2008 10:14 PM
SQL Query in coldfusion? sparky77275 Cold Fusion 1 05-06-2008 09:05 PM
How to export from MS SQL 2000? dat do MS SQL 1 05-06-2008 06:14 PM
i want to export data from html forms but i don't know how.? red-man HTML & DHTML 1 05-06-2008 05:46 PM
Create a form in visual Studio and export the form layout as xml to be recreated.? Oso XML & XUL 0 05-06-2008 01:45 PM

Your Ad Here

All times are GMT. The time now is 01:09 AM.