I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right way. I've looked at bcp, but I can't figure out how to put the quotes around the fields (except concatenating them to the field values, which is ugly). I guess I could do it with sqlcmd and -o, but that seems ugly for the same reason.
Is there a bcp way to do it?
Is there a reasonable sqlcmd way to do it?
Is there some great, simple utility built into the Management Studio that I'm just overlooking?
To export the data, you can: Right mouse click on your database >> tasks >> export data. or copy/paste from/to table data view.
However, if you prefer to export SQL query results to a text file via a Wizard, we have your back. To begin with, right-click the database in SQL Server Management Studio or SSMS. Then, select the Import or Export data option and head to Export Data under Tasks. Next, open the SQL Server Import and Export wizard.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With