<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Executing a Stored Procedure in MS SQL from arcpy.ArcSDESQLExecute in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366558#M28929</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case you haven't read it:&amp;nbsp; &lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/python/executing-sql-using-an-egdb-connection.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/python/executing-sql-using-an-egdb-connection.htm"&gt;Executing SQL using an EGDB connection—Help | ArcGIS Desktop&lt;/A&gt; .&amp;nbsp; There are &lt;EM&gt;lots&lt;/EM&gt; of caveats when using ArcSDESQLExecute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would help to post some of the code, Python and/or SQL.&amp;nbsp; There are numerous variables in play when using ArcSDESQLExecute and we haven't been given information on many.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;What version of ArcGIS Desktop, or is it ArcGIS Pro you are using?&lt;/LI&gt;&lt;LI&gt;What version is the enterprise geodatabase?&lt;/LI&gt;&lt;LI&gt;What DBMS and version?&amp;nbsp; (You mention MS SQL Server but no version)&lt;/LI&gt;&lt;LI&gt;What version of local DBMS clients are installed?&amp;nbsp; &lt;EM&gt;(&lt;/EM&gt;It appears SQL Server Native Client 11.0, any others?)&lt;/LI&gt;&lt;LI&gt;If ArcGIS Desktop/ArcMap:&lt;OL&gt;&lt;LI&gt;Is Background Processing enabled or disabled?&lt;/LI&gt;&lt;LI&gt;Is 64-bit Background geoprocessing installed?&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Does your SP work against registered tables, unregistered, or both?&lt;/LI&gt;&lt;LI&gt;If working with versioned data, are you using the versioned views?&lt;/LI&gt;&lt;LI&gt;Have you tried running the SQL within a transaction using ArcSDESQLExecute?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those are the first questions that come to mind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Jan 2018 15:25:29 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2018-01-22T15:25:29Z</dc:date>
    <item>
      <title>Executing a Stored Procedure in MS SQL from arcpy.ArcSDESQLExecute</title>
      <link>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366556#M28927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Store Procedure in MS SQL Server, which does his work correctly as long as I start (exec) it directly in the database (with sqlcmd or MS&amp;nbsp; SQL Server Managment Studio). Because this SP is embedded in a bigger dataprocessing job with Python and arcpy I want to start it with arcpy.ArcSDESQLExecute and .execute(). Now I get an error-Message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"AttributeError: ArcSDESQLExecute: SreamExecute ArcSDE Extended error 24000 [Microsoft][SQL Server Native Client 11.0]Invalid cursor state"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;In my SP there are many DELETE, SELECT, INSERT statements. When I ommit them, I get no error message an I get the my excepted return-code (which I have coded in the SP depending of the result of the Procedure).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I use a SP with only a simple SELECT statement, I get back a Python list with the result of the query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How does I have to formulate my SP, to have done the work with SELECT etc. and get back my return code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jan 2018 17:40:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366556#M28927</guid>
      <dc:creator>PiusHauenstein</dc:creator>
      <dc:date>2018-01-19T17:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a Stored Procedure in MS SQL from arcpy.ArcSDESQLExecute</title>
      <link>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366557#M28928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;possibly try pypyodbc instead of arcpy to implement SQL transactions, this one has native SQL drivers compared to arcpy.ArcSDESQLExecute(). Possibly will solve your issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jan 2018 03:26:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366557#M28928</guid>
      <dc:creator>ChrisPedrezuela</dc:creator>
      <dc:date>2018-01-22T03:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a Stored Procedure in MS SQL from arcpy.ArcSDESQLExecute</title>
      <link>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366558#M28929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case you haven't read it:&amp;nbsp; &lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/python/executing-sql-using-an-egdb-connection.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/python/executing-sql-using-an-egdb-connection.htm"&gt;Executing SQL using an EGDB connection—Help | ArcGIS Desktop&lt;/A&gt; .&amp;nbsp; There are &lt;EM&gt;lots&lt;/EM&gt; of caveats when using ArcSDESQLExecute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would help to post some of the code, Python and/or SQL.&amp;nbsp; There are numerous variables in play when using ArcSDESQLExecute and we haven't been given information on many.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;What version of ArcGIS Desktop, or is it ArcGIS Pro you are using?&lt;/LI&gt;&lt;LI&gt;What version is the enterprise geodatabase?&lt;/LI&gt;&lt;LI&gt;What DBMS and version?&amp;nbsp; (You mention MS SQL Server but no version)&lt;/LI&gt;&lt;LI&gt;What version of local DBMS clients are installed?&amp;nbsp; &lt;EM&gt;(&lt;/EM&gt;It appears SQL Server Native Client 11.0, any others?)&lt;/LI&gt;&lt;LI&gt;If ArcGIS Desktop/ArcMap:&lt;OL&gt;&lt;LI&gt;Is Background Processing enabled or disabled?&lt;/LI&gt;&lt;LI&gt;Is 64-bit Background geoprocessing installed?&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Does your SP work against registered tables, unregistered, or both?&lt;/LI&gt;&lt;LI&gt;If working with versioned data, are you using the versioned views?&lt;/LI&gt;&lt;LI&gt;Have you tried running the SQL within a transaction using ArcSDESQLExecute?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those are the first questions that come to mind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jan 2018 15:25:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366558#M28929</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-01-22T15:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a Stored Procedure in MS SQL from arcpy.ArcSDESQLExecute</title>
      <link>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366559#M28930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found the reason:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	I had to add the «SET NOCOUNT ON» to the Stored Procedure&lt;/P&gt;&lt;P&gt;2.	The Transaction Counts have to be balanced («Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements»). Therefore I had to reorganize the procdure (BEGIN TRY, BEGIN TRANSACTION, END, COMMIT TRANSACTION, BEGIN CATCH …)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nevertheless, Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Von: Joshua Bixby  &lt;/P&gt;&lt;P&gt;Gesendet: Montag, 22. Januar 2018 16:26&lt;/P&gt;&lt;P&gt;An: Pius Hauenstein &amp;lt;pius.hauenstein@alumni.ethz.ch&amp;gt;&lt;/P&gt;&lt;P&gt;Betreff: Re:  - Re: Executing a Stored Procedure in MS SQL from arcpy.ArcSDESQLExecute&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;lt;https://community.esri.com/?et=watches.email.thread&amp;gt; GeoNet &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Re: Executing a Stored Procedure in MS SQL from arcpy.ArcSDESQLExecute &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reply from Joshua Bixby &amp;lt;https://community.esri.com/people/bixb0012?et=watches.email.thread&amp;gt;  in Python - View the full discussion &amp;lt;https://community.esri.com/message/743823-re-executing-a-stored-procedure-in-ms-sql-from-arcpyarcsdesqlexecute?commentID=743823&amp;amp;et=watches.email.thread#comment-743823&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jan 2018 15:45:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-a-stored-procedure-in-ms-sql-from-arcpy/m-p/366559#M28930</guid>
      <dc:creator>PiusHauenstein</dc:creator>
      <dc:date>2018-01-22T15:45:14Z</dc:date>
    </item>
  </channel>
</rss>

