How to export SQL Server 2005 query to CSV

Posted by jmgant on Stack Overflow See other posts from Stack Overflow or by jmgant
Published on 2009-04-28T19:21:58Z Indexed on 2010/03/17 22:51 UTC
Read the original article Hit count: 333

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about sql-server-2005