Monday, February 20, 2012

Programatic or expression for failure

Hello,

Is there a way is a script task or via a procedural expression to tell if a package is going to fail because of an error?

This would be used to fire something which should occure if the max number of errors/error severity to fail the package had been reached

Thanks

Paul

Hi Paul,

I'm unaware of a way to tell before execution that a package is going to encounter n number of errors. You can use the DtExec /Validate switch (or check the Validate package without executing checkbox in DtExecUI) to perform a package validation, but validation will not catch all conditions that can raise errors during execution.

You may want to check into SSIS Event Handlers. These allow you to respond to error conditions.

Hope this helps,

Andy

|||

Sorry I did not clarify the problem very well.

When a package is running and an OnError event handeler is called i want it to do somthing specific if the package will fail because of the error. usually a OnError would cause the package to fall over but i have changed the package to allowed errors to be 3 so not every error would cause the package to fail.

e.g.

Error 1 would send an email

Error 2 would send an email

Error 3 would send an email and move a file (the package would fail at this point)

|||

Hi Paul,

Oh, ok. Count the errors.

Create a package-scoped variable called iErrorCount of Int32 data type. Make the first task in your OnError Event Handler a Script Task that contains code similar to the following:

Code Snippet

Dim iErrCount as Integer =

Convert.ToInt32(

Dts.Variables("iErrorCount").Value)

iErrCount += 1

If iErrCount >= 3 Then

...

Hope this helps,

Andy

No comments:

Post a Comment