June 29, 2008 at 8:50 pm
Hi! need help. 😀 I have different packages that extract files from a specific folder/location. These files may be of different types (.xls, .txt. .csv, .xml, .etc). I have created separate packages on extracting files for each type. My problem is running the appropriate package automatically/programatically depending on the type of files available. (e.g. I wish to run the Package for extracting text files when .txt files exist on the folder. Or run packages for extracting text and excel files if both .txt and .xls files exist on the folder.) Can this be done through a Script Task? If so, please lend me some sample codes:D Thanks guys!:)
June 29, 2008 at 8:57 pm
well you will have to loop through the folder where these files will exists.
you cna use the for loop component task in SSIS to take care of this, or VBScript.
check http://www.sqldts.com or http://www.sqlis.com for more examples..
Maninder
www.dbanation.com
June 30, 2008 at 12:53 am
Hi Mani Singh,
I have browsed over the For Loop Samples on http://www.sqlis.com but found no codes that matched my case.
🙁 One is just looping over all the packages until a given time..other is looping over all the packges with specified number of times. I would just want to loop through selected package/s given a condition. Sorry, but I'm still a newbie. Thanks!
June 30, 2008 at 5:55 am
I would use a ForEach Loop container that uses the Foreach File Enumerator and assign the filename to a variable. Inside the ForEach loop container, using the filename variable, you can get the filetype. Add the all the packages you want to call to the ForEach loop and use Precedence Contraints Expressions that check the filetype and direct the specific file to the correct package.
July 7, 2008 at 2:28 am
Hi. Thanks for the response. I tried doing the directions above but my new package is not working. I have placed all the packages inside the For Each Loop Container but I could not make a Precedence constraint from the container. I tried putting them outside the container, and successfully made a predence constraint but package is not working. Can you please post a sample package for this? Thanks!:D
July 7, 2008 at 11:31 am
Try adding a blank script task inside your Foreach loop as the first task to execute, dont put any code in it so that it is just there as a starting point, by adding this task you can then add the precedence constraints to the next task that must execute. It might not be the best way but it works for me.
July 8, 2008 at 7:22 am
Either create a Script Task to load all file names of the specific type into a variable (an object variable) and do a "ForEach Loop" on that variable, or create a ForEach Loop on the directory and create a ScriptTask to get the file type into a local variable and do a condition on the file type desired.
You could even spawn seperate SSIS packages from one control, passing the file name as a variable to the file-type specific packages. This would allow you to run each file in parellel instead of in series by type.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply