Link to home
Start Free TrialLog in
Avatar of danburyit
danburyit

asked on

Best ways to cancel package execution

I have a package that is using a Script Task to set a package variable. If the variable doesn't get a valid value (a date) is there a command to cancel the package execution?

Thanks
Avatar of PedroCGD
PedroCGD
Flag of Portugal image

Try use DTS events inside Script to do that.
Example:
Dts.Events.FireError(-1, "", "SSIS - @LastRunDate_Dados>@StartDate! Correct the problem and try again!", "", 0)

Helped?
regards
ASKER CERTIFIED SOLUTION
Avatar of Steve Hogg
Steve Hogg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of danburyit
danburyit

ASKER

Of course! I forgot about that. Thank you!
Setting the following property in the script code can determine if the precedent constraint (outlined above) will succeed or fail.

If (My code does what I want it to) Then
   Dts.Results.Success
Else
   Dts.Results.Failure
End If

If it's "Failure" then the precedent constraint will stop the package execution. Only in this case you don't need to evaluate anything in the precedent constraint. Just leave it with default value.

ConstraintDefault.png