python script not running as a SQL Server scheduled job

4779
1
12-12-2012 10:02 AM
RobertHu
New Contributor II
Python 2.7
ArcGIS 10.1 (sp1)
ArcSDE 10.1 (sp1)
SQL Server 2008 R2 Standard (sp2)
Windows Server 2008 R2 Standard (sp1)

Run a batch file, which calls a python script, as SQL Server scheduled job, if the python script includes "import arcpy" statement, the script will fail without leaving any error message. The script works fine without the "import arcpy" statement. Tried samething as a system scheduled task, the results are same.

While running the batch file from command line, it works fine with or without the "import arcpy" statement.

Anyone ever experienced same thing, and have a clue?

Thanks in advanced!
0 Kudos
1 Reply
RashanWalker
Esri Contributor
Here are the instructions to run a Python script as a scheduled task in SQL Server:
1. Open SQL Server Management Studio
2. Select SQL Server Agent
3. Right-click on "Jobs" and select "New Job"
4. On the "Steps" page, select "New" (At the bottom of the screen)
5. Select "Operating System (CmdExec)" for the "Type"


-- Sample Python script (C:\Python26\HELLO_931.py)
import arcpy
print 'HELLO'


-- Type in the following information in the "Command" window
cd C:\Python26
HELLO_931.py
0 Kudos