How do I export a SQL table to a csv format

  • Im trying to export Table A to a csv file format, but I do not see that option anywhere in connection manager, SSIS. I see that you can export to a flat file, which will give you a .txt extension, but I want it to be a csv file.

    If you could, please provide as much detail as possible on how I can set up a SSIS package that exports a SQL table to a csv file format.

    Thank you

  • koln (8/19/2008)


    Im trying to export Table A to a csv file format, but I do not see that option anywhere in connection manager, SSIS. I see that you can export to a flat file, which will give you a .txt extension, but I want it to be a csv file.

    If you could, please provide as much detail as possible on how I can set up a SSIS package that exports a SQL table to a csv file format.

    Thank you

    you can export data from Table A to csv file using same flat file option. just change the file extension to .csv and have the column delimeter as comma (,).

  • use bcp tablename out tablename.csv that should do it.

  • Could you please provide more detail ?...it needs to be part of a package and Im using a select query to pull out various fields out of Table A (not the whole table)

    thank you

  • BCP FUNCTIONS are below

    bcp tablename out table.csv -S servername then the options below what you would like. if you dont want to use command line you can use

    the data transformation service and export. click next select the server you want and db click next then destination select textfile in the file name type tablename.csv click next it will then ask you what you want to copy. select copy table it will then ask you what table and what you want to copy with what delimiter you want select your options and click next you can then tell it when you want it to run and then click next it will run in to a file. regards, Terry

    usage: bcp {dbtable | query} {in | out | queryout | format} datafile

    [-m maxerrors] [-f formatfile] [-e errfile]

    [-F firstrow] [-L lastrow] [-b batchsize]

    [-n native type] [-c character type] [-w wide character type]

    [-N keep non-text native] [-V file format version] [-q quoted identifier]

    [-C code page specifier] [-t field terminator] [-r row terminator]

    [-i inputfile] [-o outfile] [-a packetsize]

    [-S server name] [-U username] [-P password]

    [-T trusted connection] [-v version] [-R regional enable]

    [-k keep null values] [-E keep identity values]

    [-h "load hints"]

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply