Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

how to read dynamically changing source excel files Expand / Collapse
Author
Message
Posted Tuesday, May 08, 2012 9:28 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 01, 2013 9:12 PM
Points: 20, Visits: 155
Hi All SSIS Gurus
i need help. i have a ssis package which loop through the excel files and import the data into sql table. it is working fine with reading multiple files in a folder. issue is file names has date time stamp means file name changes everyday and i couldn't figure out how to accomodate new file names into my package. read few articles and they talk about using script task. could anyone please give me details instruction about the script because i have no idea from where i should start writing the script. please help...

Thanks
Post #1296859
Posted Tuesday, May 08, 2012 11:57 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:31 PM
Points: 12,239, Visits: 9,212
You don't need a script. You can specify a wildcard in your For Each Loop container.
For example:

myExcelFile*.xls, where * takes place of the timestamp.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1296896
Posted Wednesday, May 09, 2012 12:04 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 01, 2013 9:12 PM
Points: 20, Visits: 155
this is what i am doing and it works fine for multiple files. but when i have to execute the package next time my file name changed (new date time + some random numbers). problem is in variable we specify the first file name imported and that file name is changed now. how i can deal with that? i hope i make some sense.
Post #1296902
Posted Wednesday, May 09, 2012 12:18 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:31 PM
Points: 12,239, Visits: 9,212
This is what I do:

put a for each loop with a file enumerator on the source folder and specify a wildcard in the filename.
Specify that the full path should be retrieved and I put this in a variable.
On the Excel connection manager, I specify an expression using this variable.

Set DelayValidation = TRUE on the dataflow.
Normally that's all you need to do.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1296908
Posted Wednesday, May 09, 2012 12:23 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 01, 2013 9:12 PM
Points: 20, Visits: 155
i specified 2 varibales at package level and used then in for each loop and excel source connection
SourceFileName-- specifies file name can't use wild card doesn't work

SourceFilePath--specifies folder address
how to reterive the full path (including file name) into a varibale? we need to go through the files in the folder how we can do it without script?
please elaborate if u can
Post #1296912
Posted Wednesday, May 09, 2012 12:37 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:31 PM
Points: 12,239, Visits: 9,212
Looping over files with the Foreach Loop



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1296917
Posted Wednesday, May 09, 2012 4:14 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 01, 2013 9:12 PM
Points: 20, Visits: 155
as i mentioned earlier this is what i am doing and it works fine as long as file name doesn't change. my problem is file name changes every day.
Post #1297494
Posted Wednesday, May 09, 2012 11:23 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:31 PM
Points: 12,239, Visits: 9,212
How does such a filename look like?



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1297589
Posted Wednesday, May 09, 2012 11:27 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 01, 2013 9:12 PM
Points: 20, Visits: 155
thanks for your time. after struggling for a day and half i figured out what needs to be there in script so that it can pick all the file names and pass it on to dataflow.
Post #1297591
Posted Thursday, December 27, 2012 7:58 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, February 04, 2013 12:32 PM
Points: 1, Visits: 18
HI ,
Can I get the script also.

Thanks,
Post #1400624
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse