run pythin script in sql server agent

coool sweet 61 Reputation points
2021-12-30T00:06:34.147+00:00

hi

i have .py file in my local machine .which when i run in pycharm loads rile rom URL.

now i need to run same file on sql server agent.

now sure how to do it,do i need to put my file on server folder?

how to run using sql server agent.

SQL Server Other
{count} votes

1 answer

Sort by: Most helpful
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2021-12-30T02:53:01.11+00:00

    Hi @coool sweet ,

    Yes, suggest you putting the python file on the same server with SQL server.

    Please follow below steps;

    When you creating a SQL Server Agent job step, please select:

    1. Step type: Operating system (CmdExec)
    2. Run as: here you can use Agent service account (less secure) or better option is to create dedicated service account and register it as a proxy account. If you decide to use Agent service account, you will be granting Server Admin privileges to python scripts.
    3. In command type: "C:\Windows\System32\cmd.exe" "python C:\Python\HL.py"

    161322-screenshot-2021-12-30-105038.jpg

    Please refer to this similar thread Call Python file from within SQL Server.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.