I have executed a stored procedure and want to export this layer to a shapefile. I feel like this should be an easy solution. I tried using arcpy.CopyFeatures_management and it threw an error. I am not sure if CopyFeature is meant for sql server tables.
I am running ArcGIS 10.1. I am using SQL server 2012 with geography data type. The table is not registered with the geodatabase. The error is below:
RuntimeError: Object: Error in executing tool
<<< Process finished. (Exit code 1)
Below is my code:
import pyodbc
import arcpy
sqlserver = pyodbc.connect('DRIVER={SQL Server};SERVER=sqlserver;DATABASE=AndrewSandbox;Integrated Security=True')
cursor = sqlserver.cursor()
table = cursor.execute("SELECT * FROM TEMPLINE")
arcpy.CopyFeatures_management(table, "D:\Python\WaterSage\Viability\TestExport.shp")