April 4, 2009 at 7:25 am
i have an SSIS package, that do some steps, where i nthe first one it try to move files from folder A to B.
if there are no file that exist, the Job which run's the SSIS package,exit with an error.
how can i in the SSIS end the package withought an error (and write to the event viewer that the SSIS has finished with no error beacuse no files were found)
Thanks i nadvance
peleg
April 5, 2009 at 5:19 pm
Please provide more details. How are you attempting to move the files? etc
April 6, 2009 at 1:31 am
i am using a BAT file with a simple move command
April 6, 2009 at 3:04 am
Are you using a Foreach/File container?
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
April 6, 2009 at 3:32 am
no, just :
MOVE /Y c:\x\*.txt c:\y\
April 6, 2009 at 8:52 am
I would recommend using a script task in SSIS. You can search on the FileSystemObject class... it has an Exists method for both files and folders.
After searching on the class, if you would like to use it let me know what you are thinking of doing (english explanation of what you want the code to do) and I would be happy to provide some direction on writing the script task.
April 6, 2009 at 9:02 am
the FileSystemObject i know from vbscript, where do i find it in the SSIS?
what i want to to is :
if there are files in the Folder them move them from X to Y, and move the the next step in the SSIS.
if there are NO file, then exit the SSIS, reporting of a ending the job but not on as failure (like it happens to me today).
thanks
Peleg
April 6, 2009 at 9:09 am
Phil Parkin (4/6/2009)
Are you using a Foreach/File container?
You might want to look at using the For Each container. You can configure it to only move the files it finds. If it does not find any then it does not try to move any.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
April 6, 2009 at 9:25 am
You might want to look at using the For Each container. You can configure it to only move the files it finds. If it does not find any then it does not try to move any.
how do you do that?
any way if there are no file i want to exit the SSIS and not continue, beacuse the next step depend's on that, that there files i nthe new folder!
April 6, 2009 at 9:53 am
I will have to agree with Alvin on this one. You can either create an Execute Process task to move from Folder A to folder B and then create a "For Each" task set to the Foreach File Enumerator linked to Folder B (see BOL for more info on this task) with your processing inside or you can create a "For Each" task to Folder A, process the file, and then move that specific file.
FYI, when I move a file in a For Each loop I use a Script task with something like this:
Public Sub Main()
Dim f As New IO.FileInfo(Dts.Variables("TextFile").Value.ToString)
If Not IO.Directory.Exists(Dts.Variables("ProcessedFolder").Value.ToString) Then
IO.Directory.CreateDirectory(Dts.Variables("ProcessedFolder").Value.ToString)
End If
IO.File.Move(Dts.Variables.Item("TextFile").Value.ToString, Dts.Variables("ProcessedFolder").Value.ToString + "\" + f.Name)
Dts.TaskResult = Dts.Results.Success
End Sub
Note: this will fail if anything has the file open.
April 6, 2009 at 9:59 am
Timothy J Hartford (4/6/2009)
I will have to agree with Alvin on this one. You can either create an Execute Process task to move from Folder A to folder B and then create a "For Each" task set to the Foreach File Enumerator linked to Folder B (see BOL for more info on this task) with your processing inside or you can create a "For Each" task to Folder A, process the file, and then move that specific file.FYI, when I move a file in a For Each loop I use a Script task with something like this:
Public Sub Main()
Dim f As New IO.FileInfo(Dts.Variables("TextFile").Value.ToString)
If Not IO.Directory.Exists(Dts.Variables("ProcessedFolder").Value.ToString) Then
IO.Directory.CreateDirectory(Dts.Variables("ProcessedFolder").Value.ToString)
End If
IO.File.Move(Dts.Variables.Item("TextFile").Value.ToString, Dts.Variables("ProcessedFolder").Value.ToString + "\" + f.Name)
Dts.TaskResult = Dts.Results.Success
End Sub
Note: this will fail if anything has the file open.
You can use a File System Task to do the move. It requires much less programming. There's no need to use ActiveX or VB script for moving files anymore.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
April 6, 2009 at 10:48 am
You can? Oooh! I got to learn something new! Thanks, Alvin, I will have to give that a try (I have never noticed that task). Come from a programming background... but as always the first approach is seldom the best!
April 6, 2009 at 1:30 pm
ok
but if there are no file to move
how can i prevent from the SSIS to go to the next step?
April 6, 2009 at 1:39 pm
If your logic is in a for each loop than if there is no objects in the array nothing within that loop will be executed (0 items = execute 0 times).
April 6, 2009 at 1:48 pm
peleg k (4/6/2009)
okbut if there are no file to move
how can i prevent from the SSIS to go to the next step?
Inside the Foreach Loop Container, I would use a Script Task to increment the value of a variable each time the loop executes. Then I would use that variable in the Precedence Constraint and only go forward if the value is greater than 0.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
Viewing 15 posts - 1 through 15 (of 22 total)
You must be logged in to reply to this topic. Login to reply