I have the following code in a stored procedure called by a DTS Execute SQL Task:
--------------------------
----------
----------
-------
-- Error handler for Errors encountered
ErrorHandler:
SELECT @Severity = severity
FROM master..sysmessages where error = @ErrorNumber
EXEC CreateError @ErrorID = @ErrorID OUTPUT,
@ErrorDate = @ErrorDate,
@LogonUser = @LogonUser,
@Source = @ProcName,
@CurrentTask = @CurrentTask,
@ErrorNumber = @ErrorNumber,
@ErrorMessage = @ErrorMessage,
@TargetSite = NULL,
@StackTrace = NULL,
@Severity = @Severity,
@BatchID = @BatchID
IF @ErrorNumber = 50000
RAISERROR(@ErrorMessage, @Severity, 1)
RETURN (-1)
--------------------------
----------
----------
-------
An error is occurring, so the SP should be returning a -1, yet the task workflow always returns success regardless of whether it succeeds or fails. What do I need to set in the task to make it recognize that the SP failed???
Note: I have Execute SQL Tasks in other packages using SPs with the exact same code as above that work perfectly. We use a template to create our packages, so they all work basically the same way. I can't see any difference between this one that always succeeds and the ones that succeed or fail appropriately.
Start Free Trial