Question : SSIS Read Excel File Name

Hi Experts I do need a little help in figuring out how to load a part of a file name into my table.
I have some excel files on my network and I need to load these files into a table in my database.I am giving a sample of my file location and the Name here. There will be 15- 20 files for every load, So I need to loop around all the files.

File Location: \\MyNetwork\Drive1\Dropbox\Import\Folder1\
FileName:4Q09 Data File.xlsx

Now I have a column in my Destination table called QuarterSeq and I need to populate that field by taking the part of my file name. Like
If the File name starts with '4Q09' I need to populate the destination column as 20094 that is like [YYYYQ]

and If the File name starts with '1Q10' I need to populate the destination column as 20101. Please help me in Solving this. Thanks in Advance.

Answer : SSIS Read Excel File Name

Highlevel- i  suggest two foreach tasks to loop through for each prefix (4Q09, for example), map the path to  a variable, and use a data flow to map as you have layed out.

Repeat this process for each filename:
1.  Add a string variable to hold your Excel path
2.  Add a foreach loop container
3.  Open the foreach and set your enumerator to "Foreach File Enumerator"
4.  Folder set to: \\MyNetwork\Drive1\Dropbox\Import\Folder1\
5.  Files: 4Q09*.xlsx
6.  Click "Variable Mappings" to map your excel path to your variable
7.  Index wil be 0, then select your variable name
8.  Add a data flow and add an Excel source
9.  Once your Excel source is in your Connection Manager (usually at the bottom), you will want to set your "Expressions" and set to your variable.   @[User::<<variable name>>]
10.    Then just add your destination and map your columns

Repeat this process for the other file name type - I would just add a second variable and foreach loop.   You could run this simultaneously.
Random Solutions  
 
programming4us programming4us