2

I have a SQL job whose step of 'PowerShell' type does 'exit 1' if encounters an error i.e.

$ErrorActionPreference='stop'; trap{"$_"; exit 1}

Problem is, SQL Server doesn't pay attention to that exit code, and reports "The step did not generate any output. Process Exit Code 0. The step succeeded."

Any idea how to successfully tell SQL Server from a PowerShell step that something went wrong?

Thanks in advance.

1

throw "Failure" will work. See this MSDN forum post for additional information:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.