我们要求 SSIS 脚本任务在某些情况下失败
If var_status = "Y"
Msgbox("Error Found")
Dts.TaskResult = ScriptResults.Failure
End If
但是当我们运行它时,它会进入 IF 条件,但不会使脚本任务失败。
任何人都可以请建议
我们要求 SSIS 脚本任务在某些情况下失败
If var_status = "Y"
Msgbox("Error Found")
Dts.TaskResult = ScriptResults.Failure
End If
但是当我们运行它时,它会进入 IF 条件,但不会使脚本任务失败。
任何人都可以请建议
If var_status = "Y"
    Msgbox("Error Found")
    Dts.TaskResult = ScriptResults.Failure
    Return
End If
假设 **ScriptResults.Failure与Dts.Results.Failure相同
您可以使用此技术:
尝试 {
   //Code goes here that may throw exception or succeed
   Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception e)
{
   //Outputs a message to the Output window of SSDT/BIDS
   Dts.Events.FireError(-1, "My Task Name", e.message, String.Empty, 0);
  // Makes a package fail (or intercept in Event Handler)
   Dts.TaskResult = (int)ScriptResults.Failure;  
}