Daniel E.
Daniel E.

Reputation: 2059

SSIS Foreach loop, send email if no file is present?

I have a very simple SSIS package that grabs 1 or more flat files and imports the data into a SQL Server 2012 table, then a separate package archives the file.. The packages work perfectly, but I want it to warn me if there is no file present when it starts.

I know that the Foreach loop generates a warning when there are no files:

Warning: The For Each File enumerator is empty. The For Each File enumerator did not find any files that matched the file pattern, or the specified directory was empty.

I have not been able to find a way to use that warning to trigger an email, as it does not cause the package to fail, and I am not sure if there is a constraint or expression that can trigger a next step based on a warning.

I use the for each loop to populate a variable @[User::FileName] with any filename matching the pattern which is preset.

A notify operator task with the expression @[User::FileName]=="" and completion or success fires no matter what, if there is a file or not.

Is this possible in SSIS?

Upvotes: 2

Views: 5016

Answers (1)

gannaway
gannaway

Reputation: 1882

You can handle warnings by implementing the OnWarning event handler.

enter image description here

Upvotes: 7

Related Questions