SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 General SSIS package to export any table into .csv
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sql_er
Constraint Violating Yak Guru

267 Posts

Posted - 03/18/2013 :  14:32:22  Show Profile  Reply with Quote
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, but could not come up with a full blown solution.

Any advise is appreciated.

Thanks!

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 03/18/2013 :  14:37:51  Show Profile  Reply with Quote
does the table structure vary at runtime? then only way is to create object of data flow task programatically inside script task.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql_er
Constraint Violating Yak Guru

267 Posts

Posted - 03/18/2013 :  14:44:50  Show Profile  Reply with Quote
Yes, input tables can be of any structure, so they will vary from run to run.

When you say "create object of data flow task programatically inside script task" are you referring to SSIS API?

Thank you!
Go to Top of Page

yosiasz
Flowing Fount of Yak Knowledge

USA
1634 Posts

Posted - 03/18/2013 :  21:08:37  Show Profile  Click to see yosiasz's MSN Messenger address  Reply with Quote
create destination table programatically by reading csv file and dynamically creating a table that matches the csv file.

<><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 03/19/2013 :  01:11:48  Show Profile  Reply with Quote
quote:
Originally posted by sql_er

Yes, input tables can be of any structure, so they will vary from run to run.

When you say "create object of data flow task programatically inside script task" are you referring to SSIS API?

Thank you!



Something like this

http://www.selectsifiso.net/?p=288

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql_er
Constraint Violating Yak Guru

267 Posts

Posted - 03/19/2013 :  09:19:13  Show Profile  Reply with Quote
Thanks guys. Using SSIS API seems quite involved for seemingly simple task.

I'll be looking into using bcp as a starting point.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 03/19/2013 :  11:39:13  Show Profile  Reply with Quote
hmm..that would be much better. you can put logic to generate column headers also dynamically in bcp

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000