Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Change flat file source programatically?

Author  Topic 

Ben Taylor
Starting Member

6 Posts

Posted - 2011-01-31 : 12:23:00
Hello,
I need to use a SSIS package on SQL Server 2008 R2 to import lots of CSV files, with the same format.
I want to load a package from the server (or from a DTSX file), change the file path of the source of the flat file, then execute it - but I cannot find how to do this.
I don't want to have to construct the package from scratch programatically (to do so would be too complicated, there are 98 columns), but I have already designed it and saved it on the server.

I remember this always used to be possible with the old DTS, so how is it that it is so opaque in SSIS?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-01-31 : 12:40:01
Look for DTEXEC and how to change the source connection via parameter.
Look for FOR in DOS-Batch to loop through all the flat files and use the DTEXEC with the DOS loop variable inside the DTEXEC parameter.
That's all


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Stamey
Starting Member

14 Posts

Posted - 2011-02-01 : 14:54:59
Create a Variable in your package. Call it FileName. Set the connection string for your flat file to be "@[User::FileName]", through the Expression Builder, by clicking on Expression in the Properties window while you have your flat file connection manager selected. Once this is done you can specify the file name as an argument to your package when you run it.
If you want to further automate it, create another package with logic to handle the files and have it call a "child" package, your original package, with the argument of each file the "parent" package finds/processes.

Chris
Go to Top of Page
   

- Advertisement -