The easiest way to do this would be to use the SQLCMD command-line utility to export a query or query file result set, changing the column separator value to a comma.

SQLCMD -S MyInstance -E -d sales -i query_file.sql -o output_file.csv -s ,

Advertisements