Create a stored procedure which contains the select statement you wish to use. Make sure that the select statements creates the XML data the way you want it using the FOR XML clause.
Then use BCP and use it to run the stored procedure using the QUERYOUT switch giving to the three part name to the stored procedure as well as the path to the file you wish to put the data into.
You can also do this with DTS (SQL 2000 and older) or SSIS (SQL 2005 and newer).
Last Wiki Answer Submitted: October 9, 2008 6:14 am by Denny Cherry64,520 pts.