Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 EXPORT QUERY To XML File

Author  Topic 

jooorj
Posting Yak Master

126 Posts

Posted - 2011-05-20 : 09:05:33
How can I Export the following QUERY to xml file, using T-SQL

select * from Table1,table2
where table1.ID=table2.ID
order by Table2.ID

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2011-05-20 : 09:20:34
while exporting data to xml file you need to mention the column names in the select list.
you can do this using "bcp"
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-05-20 : 09:37:54
To expand on what ahmeds08 suggested, you will need to formulate the XML in your query using one of the xml directives. Perhaps the easiest is to use xml auto - see here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=160846
Go to Top of Page
   

- Advertisement -