Qpdert
Qpdert

Reputation: 1

Dynamic API Query Consumption from a SQL Server Agent Job

Question: I'm working with a stored procedure that consumes a dynamic API query using sp_OA* procedures and inserts data into a table. When I execute this stored procedure manually, it works perfectly and inserts data as expected. However, when I run the same stored procedure from a SQL Server Agent Job, the job executes successfully without any errors, but no data is inserted into the target table.

I've checked permissions and configurations like enabling Ole Automation Procedures, and the API endpoint is accessible. The stored procedure involves calling an external API, parsing JSON, and inserting data. The only difference observed so far is the execution context between manual execution and job execution.

What could be causing this discrepancy, and how can I troubleshoot or resolve it to ensure the SQL Server Agent Job inserts data correctly when consuming the API?

I have already tried:

Any insights, similar experiences, or solutions would be greatly appreciated.

What I tried:

Manual execution of the stored procedure:

SQL Server Agent Job execution:

Environment and Permissions Checks:

What I expect:

I expected that running the stored procedure within a SQL Server Agent Job would produce the same outcome as running it manually.

Specifically, the job should:

The goal was to have the Agent Job replicate the manual execution behavior, resulting in new rows being added to the table with the data fetched from the API. However, despite the job completing without errors, no data was being inserted when run through the job, which is contrary to my expectations.

Upvotes: 0

Views: 51

Answers (0)

Related Questions