Sunday, February 26, 2012

error code from DTEXEC not 0 nor 1

I would like to send back to MS-DOS (ERRORLEVEL) an error code 2 ( different from 0 and 1) via a scripting Task.

Our package are started with the DTEXEC Utility.

In general, how can i send back a flag saying "There were warnings" during the execution of a Package

Warnings can happen with successful package executions, and for that matter, so can errors.

There are a numerous ways to figure out there were warnings though, such that a shell caller is aware of that fact.

One, capture the console output from dtexec and look through the captured text for the warning event.

Two, create a console utility which calls Package.Execute() and iterates through the .Warnings collection. If the count > 0, return what you want as the process exit code.

Three, use logging. Configure the package to use the native SSIS logging facilities to write log entires. Read the produced log provider for warning events.

Four, use a package level OnWarning event handler. Inside the event handler, set something external to the package (file, db, message queue, doesn't matter) which is readable post-execution.

No comments:

Post a Comment