September 26, 2013 at 1:18 pm
Hi everyone.
I have been tasked with building some SSIS packages to load data from a csv into the database each day. There are four file sources. Three of them are very simple because the file name is source_date.csv. The file name is predictable so creating an expression that get the current day's file is easy. One of the files is source_date_time. Because the time stamp is always a few seconds different, I don't know how to create an expression to get the file by name and load it.
What do people do when they need to have their package go out and grab the day's file if there is a time stamp in the name leading to an unpredictable file name?
September 27, 2013 at 12:31 am
Use a for each loop.
There you can use wildcards to find the correct files, for example source_*.csv.
A small tutorial:
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
September 30, 2013 at 2:24 pm
That is a great solution! Thanks Koen.
September 30, 2013 at 2:30 pm
PHXHoward (9/30/2013)
That is a great solution! Thanks Koen.
No problem, glad to help 🙂
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 2, 2013 at 12:36 pm
You can also rename the file to your liking and then import.
October 2, 2013 at 12:54 pm
Do you mean use the Foreach loop to rename the file and then use the new fixed file name to load?
That would work too.
Thanks
October 2, 2013 at 1:31 pm
ccavaco (10/2/2013)
You can also rename the file to your liking and then import.
How would you find the file to rename?
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 2, 2013 at 2:26 pm
You could rename every file in the folder to "name_date". The "good" ones would stay the same and the "bad" would be modified like the others.
October 2, 2013 at 3:05 pm
ccavaco (10/2/2013)
You could rename every file in the folder to "name_date". The "good" ones would stay the same and the "bad" would be modified like the others.
So if I have Customer_20131002_230410.txt, Customer_20131002_230412.txt and Customer_20131002_230415.txt, you would rename them all to Customer_20131002.txt?
This would drop two files in the process.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply