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?
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.