|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, January 19, 2013 5:01 AM
Points: 2,
Visits: 9
|
|
Hi, I was to import excel data into a table in SQL Server,regularly on a scheduled time.
I was able to import data from a "particular excel" into DB using Import-Export Wizard (SSIS package), executing it at scheduled time via SQL Server Agent job scheduler, perfectly.
But, now I came to know that.. the user will daily pull out an Excel Report ( perhaps with same Name+current-date as the file name) and drop that into the shared folder. Now the SQLServer Agent Scheduler ought to pick the latest excel and kindly append the data of only that file into the particular table of the database. My problem is while creating the SSIS package in wizard I will necessarily be giving - one particular excel name in the DataSource. Now how can I make it pick the latest excel in the folder and put it in the database. 
Any solution that you can suggest?
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 2:58 PM
Points: 221,
Visits: 452
|
|
You'll have to modify the package in BIDS and put an expression into the ExcelFilepath property in your connection to dynamically change the filepath at runtime. The below expression will give you "C:\MyFolder\MyExcelYYYYMMDD.xlsx"
"C:\\MyFolder\\MyExcel" + (DT_WSTR, 4) YEAR( GETDATE() )+ RIGHT("0"+(DT_WSTR, 2) MONTH( GETDATE() ),2)+ RIGHT("0"+(DT_WSTR, 2) DAY( GETDATE() ),2) + ".xlsx"
if you're not familiar with expressions I'd recommend getting a beginners SSIS book.
--------------------------------------------------------------- Mike Hahn - Future MCM 2025  Right way to ask for help!! http://www.sqlservercentral.com/articles/Best+Practices/61537/ I post so I can see my avatar  I want a personal webpage  I want to win the lotto  I want a gf like Tiffa
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, April 12, 2013 6:35 PM
Points: 3,
Visits: 134
|
|
I have seen a system where it would look at a processed directory and process all of the files in that directory, when the package had finished with a file it moved it to a new directory. Also if there was an error with the files it would then move it to an exception directory.
To do this you will not be able to use the default templates and wizards, you will have to custom work the SSIS packages.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 2:58 PM
Points: 221,
Visits: 452
|
|
|
|
|