How to export SQL Server 2005 query to CSV How to export SQL Server 2005 query to CSV sql-server sql-server

How to export SQL Server 2005 query to CSV


In Management Studio, select the database, right-click and select Tasks->Export Data. There you will see options to export to different kinds of formats including CSV, Excel, etc.

You can also run your query from the Query window and save the results to CSV.


In management studio, set query options to output to file, and in options->query results set output to file to output using comma as delimiter.


If you can not use Management studio i use sqlcmd.

sqlcmd -q "select col1,col2,col3 from table" -oc:\myfile.csv -h-1 -s","

That is the fast way to do it from command line.