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.
All Answer Wiki Contributors: Denny Cherry64,520 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Denny Cherry has over a decade of experience managing SQL Server and is currently a Sr. Database Administrator and Architect at Awareness Technologies. Denny holds several Microsoft Certifications as well as being a Microsoft MVP.
Denny Cherry has over a decade of experience managing SQL Server and is currently a Sr. Database Administrator and Architect at Awareness Technologies. Denny holds several Microsoft Certifications as well as being a Microsoft MVP.