Question

  Asked: Jul 23 2008   5:08 PM GMT
  Asked by: SQL Server Ask the Experts


Saving the results of a SQL Server 2005 table query in a XML file


SQL Server 2005, Query, SQL Query

I have data in a table on a SQL Server 2005, and I need to query this table and save the results in a XML file that conforms to a given XSD. Is there an easy way of doing this?

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
+1
Click to Vote:
  •   1
  •  0



You'll want to use the FOR XML clause when you query the table. Unforunately you can't just give SQL the XSD and have it give you the data. It may take a while to get the hang of the FOR XML clause, but once you do it'll be easy.

Take a look in Books OnLine under "FOR XML clause" for the syntax information of using the FOR XML clause.
  • AddThis Social Bookmark Button

Browse more Questions and Answers on SQL Server and Development.

Looking for relevant SQL Server Whitepapers? Visit the SearchSQLServer.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Mrdenny  |   Jul 23 2008  5:28PM GMT

Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.