SQL Job fails with no explanation

Asked by At

I have a SQL Server Agent job that has a single step which uses a python interpreter to run a Python script. The script runs successfully from the command line (using the interpreter) and produces the expected output. However, the SQL job fails, and when I look at the step in the history log, all it says is "Executed as user [user]. The step failed."

What is strange is that the SQL job appears to run everything successfully and only fails at the very end. When I use print statements and run the SQL job, it shows that it is running each step of the tool and then will even print "done" at the very end of the script, but then the job will say it failed. The python script uses a tool from a module that produces an output table showing the results and also each step of the tool and whether it succeeded or failed (I don't have access to the tool's code or control over this table). This table shows that each step of the tool succeeded, and running the tool is the only thing the script does. I have tried using "except" statements in the Python but they are not triggered--the Python script is not having any errors.

I am at a loss because the Python script is succeeding, so it doesn't give me any errors, the tool's output is saying that it ran successfully, and the SQL job won't say anything more than "the step failed". How would I get more information about what's going on?

I am pretty new to Stack Overflow, so I apologize if there are any problems with my question.

0 Answers