Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


General SSIS package to export any table into .csv


General SSIS package to export any table into .csv

Author
Message
sql_er
sql_er
SSC Veteran
SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)

Group: General Forum Members
Points: 257 Visits: 562
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!
Orlando Colamatteo
Orlando Colamatteo
SSCrazy Eights
SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)

Group: General Forum Members
Points: 8239 Visits: 14368
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
sql_er
sql_er
SSC Veteran
SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)

Group: General Forum Members
Points: 257 Visits: 562
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!
Orlando Colamatteo
Orlando Colamatteo
SSCrazy Eights
SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)

Group: General Forum Members
Points: 8239 Visits: 14368
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
CozyRoc
CozyRoc
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1150 Visits: 2235
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/


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search