How to execute SSIS package when a file is arrived at folder
-
Wednesday, March 07, 2012 6:19 AM
Hi,
Can anyone suggest answer for the below query
How can i run a package when a particular file is available in the folder?
All Replies
-
Wednesday, March 07, 2012 6:25 AM
Hi,
My suggestion is schedule a job to run every hour. Hope your package will check for file existence as a first step.
Thanks,
Guru
-
Wednesday, March 07, 2012 6:27 AM
have you considered using a File System Watcher
You can implement this via:
- A scipt code, which will call the package when a file is made available. Check http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx
- Using a custom task http://www.sqlis.com/post/file-watcher-task.aspx
- Using WMI Event watcher, where you would have to compose a WMI Query http://msdn.microsoft.com/en-us/library/ms141130.aspx
This is pretty easy to configure.
Please vote as helpful or mark as answer, if it helps
Cheers, Raunak | t: @raunakjhawar | My Blog -
Wednesday, March 07, 2012 6:30 AM
Hi,
How to check whether the file exist in the particular folder? am using the ftp task to transfer the file from FTP folder to local folder as the first component.
Regards,
Vipin
-
Wednesday, March 07, 2012 6:37 AM
Aahh...Now I get it. I would have this approach using just one Script Task
- Drop a script task on the designer pane and select a script language of choice and declare any variables, if required
- Establish a FTP session using the .NET classes
- Check is file exists using System.IO library
- If true, get file to local
Note:
There may be alternate approach available.
Please vote as helpful or mark as answer, if it helps
Cheers, Raunak | t: @raunakjhawar | My Blog- Marked As Answer by Eileen ZhaoMicrosoft Contingent Staff, Moderator Tuesday, March 13, 2012 3:32 AM
-
Wednesday, March 07, 2012 6:40 AM
you can use the file watcher task links below
http://msdn.microsoft.com/en-us/library/ms141130.aspx
This has the query as well which you need to check.
Abhinav
-
Wednesday, March 07, 2012 6:46 AM
Hi,
Place an script task in your package as a first step and follow the below code to check whether file exists on a particular folder. Once it is true then continue your FTP Task. Hope it will helps.
Dim fl As String
Dim fl_path As String
Dim file_exist As Boolean
Dim file_exists As Boolean
Dim var As Variables
Dts.VariableDispenser.LockForRead("Trigger_File_Path")
Dts.VariableDispenser.LockForRead("Job_Trigger_Path")
Dts.VariableDispenser.LockForWrite("File_Exists_Flag")
Dts.VariableDispenser.GetVariables(var)
fl = var("Job_Trigger_Path").Value + "Job_Trigger.csv"
file_exist = File.Exists(fl)
fl_path = var("Trigger_File_Path").Value.ToString()
file_exists = File.Exists(fl_path)
If file_exist = True Then
File.Delete(fl)
End If
If file_exists = True Then
var("File_Exists_Flag").Value = 1
'File.Delete(fl_path)
Else
var("File_Exists_Flag").Value = 0
End If
var.Unlock()
Thanks,
Guru
- Marked As Answer by Eileen ZhaoMicrosoft Contingent Staff, Moderator Tuesday, March 13, 2012 3:32 AM
-
Wednesday, March 07, 2012 7:41 AM
Hi Vipin,
Please, also check following, may be it's helpful -
http://www.sqlis.com/post/file-watcher-task.aspx
Regards,
Santoshhttp://microsoftbizintel.wordpress.com/
-
Wednesday, March 07, 2012 8:31 AMModerator
A WMI Event Watcher Task could help you here: http://microsoft-ssis.blogspot.com/2010/12/continuously-watching-files-with-wmi.htmlPlease mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com | Twitter
- Proposed As Answer by Eswararao C Wednesday, March 07, 2012 10:31 AM
-
Wednesday, March 07, 2012 1:58 PM
you can design youe ETL in a way that .....
you won't need to check if the file exist , the loop that is checking the files will have NO file to pick and basically it end the package , a good example is this link for text files and this link for excel files
Sincerely SH -- MCITP 2008, MCTS 2008 & 2005 -- Please kindly mark the post(s) that answered your question and/or vote for the post(s).
- Edited by Nik - Shahriar Nikkhah Wednesday, March 07, 2012 1:58 PM

