General SSIS package to export any table into .csv

  • Hi guys,

    I need to create an SSIS package that takes a table name as a parameter and exports out its data in a CSV file.

    The challenge is that if I use a data flow task and a flat file connection manager (for csv export), I have to specify the file/table structure. I will not know the table structure until the run time because it is input specific.

    Has anyone had a similar problem and implemented a solution?

    I was thinking along the lines of using C# in a script task to get the column structure of the input table, read the data and write it out into a CSV file. I could not come up with a full blown solution though.

    Any advise is appreciated.

    Thanks!

  • Calling bcp might be a better option for you than using a Data Flow since bcp does not need to be armed with the table structure if using the bcp out syntax and supplying a table name, e.g.

    bcp DatabaseName.SchemaName.TableName out ...

    You can call bcp from SSIS using an Execute Process Task and use an SSIS Expression to build the command line on the fly, or you could simply call bcp directly and skip SSIS altogether if all you need to do is dump the table to a delimited file.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Hi opc.three,

    I thought about bcp, but my sense (from what I heard as I have not worked with it much) is that there could be access issues with running bcp.

    What are your thoughts about it?

    Thank you for suggestions!

  • Not that I am aware of, in general. Maybe something in your particular environment? Define "access"? Windows? Database?

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • For the process you want to accomplish using the standard SSIS will not be much of help and will in fact make your solution even more complicated.

    If you still want to use SSIS, I would strongly recommend you check the commercial COZYROC Data Flow Task Plus. It is an extension of the standard Data Flow Task , with ability to do dynamic data flows at runtime. If you decide to use it, you can accomplish the requirement with no programming skills required, exporting arbitrary table into a flat file.

    ---
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

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

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