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 2005 Forums
 SSIS and Import/Export (2005)
 Excel file iteration using For each loop container

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2009-11-03 : 02:48:45
Dear All,
I am using the For each loop container to loop through all the excel sheets.Its working fine for me.
The issue is with lets say there are 3 files are there in the folder.
During package design i have given the default following expression:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @[User::FileName] + ";Extended Properties=\"Excel 8.0;HDR=YES\";"
In the excel path proporties ->Excel file path i have given the exact file name i.e..E:\SampleExcelFiles\Excel to upload.xls

If i change the above file name to other file name its not working.Its through an error saying that invalid source connection manager.

If anybody face the same issue,please help.

Thanks in advance,
Gangadhar

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-11-03 : 11:43:42
what is the value of @[User::FileName] and how are you assigning it? also why are you changing the file name again?

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

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2009-11-04 : 02:22:02
Well..I am assigning the @[User::FileName] in the package variable and it contains the .xls file name.
I want to change the filename due to this package will run on monthly basis.so every month the file name vary like 20091001details.xls and in the next month it will change to 20091101details.xls and so on.
The above logic is working for other Excel sheet file name change,but for initial variable stored value it is not working.
Pls help how to do the iteration through the list of files with the name changing.

Thanks In advance,
Gangadhar
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-11-04 : 11:25:00
do something like this then

CONVERT(CHAR(10), GETDATE() , 121) to get 2009-11-04. Then in the property of the for each loop go to variable mappings and work your stuff out there.

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

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2009-11-06 : 11:11:34
Hi, My problem is with the input source file name.
i need to give the different file name when the package gets executed next time.

Pls guide.
The filename may change to other as well..its not only with date with other text name also.
Go to Top of Page

AustraliaDBA
Starting Member

38 Posts

Posted - 2012-05-09 : 00:56:39
did u resolve the problem. could u please share your solution. i have same problem and couldn't figure out how to fix it

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-09 : 22:41:44
quote:
Originally posted by gangadhara.ms

Hi, My problem is with the input source file name.
i need to give the different file name when the package gets executed next time.

Pls guide.
The filename may change to other as well..its not only with date with other text name also.


but input files are in a folder and is processed by for each loop right? Then you will be getting new filename itself inside variable right? or are you trying to search for latest file among ones present in folder based on date value?

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

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-09 : 22:42:18
quote:
Originally posted by AustraliaDBA

did u resolve the problem. could u please share your solution. i have same problem and couldn't figure out how to fix it

Thanks


I have answered in your thread
hope thats what you're looking at

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

Go to Top of Page
   

- Advertisement -