Last post on BCP tonight promiseĀ  . . .

There are *many* ways of exporting an XML file from SQL, adding the section in bold below to the select in a BCP command will create XML from the search results.

BCP "select * from table FOR XML AUTO,TYPE, ELEMENTS " QUERYOUT "C:\TEST.XML" -c -t -T -S server

 

 

Ta-Dah! TheĀ  switches below in the BCP statement export the results of the query to CSV

BCP "select * from table" QUERYOUT "C:\TEST.csv" -c -t"," -r"\n" -T -S server

:-)