Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSIS Package Variable

Status
Not open for further replies.

junkmail

Programmer
Jan 7, 2001
134
US
I am new to creating ssis packages but I have one that I created via SQL management studio while importing data. What I would like to do is be able to pass the file name to the package and have it import that file instead of the way I have it now which is a specific file name. I am using SQL 2005 if that matters. Can someone explain how that gets done? preferably a way in which I can schedule it as a job.

Thanks.
 
You probably don't need to know this at this late date, but I would use a foreach loop container.

First, create a variable to hold the name of the file for subsequent steps in the package. Create and edit the foreach loop container and put your filename wildcard specification (*.txt, or ??????.csv, or INCOMING*.*, or whatever your requirements) for the collection. Have it assign the filename to the variable you have created, and all other tasks within the container can then use that variable to determine which file is being worked on.

The next iteration of the foreach loop will assign the next filename, and will stop execution where there are no more files selected. Note that you cannot specify the order in which these files are picked up; my experience is that they are retrieved in a date/time modified order, but there are techniques where you can create a sorted list of files which a web search should reveal to you readily.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top